Auto Loan Payment Chatbot
A conversational chatbot pipeline powered by OpenAI’s gpt-4o, designed to assist with missed auto loan payments. It determines the next action based on user queries and chat history. The actions include verifying client details in a Snowflake database, analyzing sentiment, or negotiating payment options.
Overview
This pipeline is designed to handle conversations with bank customers about missed auto loan payments. It's a smart customer service system that knows what to do next based on the conversation flow. It automatically chooses the right action based on context while keeping the conversation flowing naturally. It also always maintains a conversation record to stay aware of the context.
Best For
- Automating customer service interactions
- Analyzing sentiment and financial details to guide payment negotiations
- Generating human-like prompts for client communication
- Verifying client information with database integration
- Handling payment instructions and escalation scenarios
Recommended Dataset
- Any Snowflake database with an associated schema of tables and columns extracted from
DESCRIBE TABLE
. For details, see Snowflake documentation. - Any text data meant to assist with the chatbot's responses.
Prerequisites
- This pipeline uses the gpt-4o model so you'll need an OpenAI API key to use it. (You can also change the Generator's model).
- Table descriptions for retrieval:
- For each table, create a TXT file with its description. The description should be short, one or two sentences is enough. This is meant to help the Retriever find the relevant table.
- Add the following metadata to each TXT file:
table: table_name" and "table_columns: column_name - data_type
.
For example, for a table called COUNTRY, you'd create a description file called COUNTRY.TXT with the following metadata:{"table": "COUNTRY", "table_columns": "ID - INTEGER\nNAME - VARCHAR\nREGION - VARCHAR"}
. - Upload table descriptions to deepset Cloud to the same workspace where the pipeline is. For details, see Upload Files.
Potential Applications
Automated customer support system.
How It Works
- The system analyzes the conversation and decides what action to take. It can choose from seven paths: start call, user verification, sentiment analysis, information extraction, negotiation logic, payment handling, or escalation and handoff.
Components involved:root_prompt_builder
,root_llm
,conditional_router
- It then proceeds with handling the selected action:
- Start call: Creates the initial greeting and asks for verification information.
Components involved:
inititate_call_prompt_builder
,initiate_call_llm
,initiate_call_answer_builder
- User verification: Verifies the information the customer provided against a Snowflake database. Then, it either confirms their identity or asks for correct information.
Components involved:
verification_prompt_builder
,verification_llm
,verification_success_adapter
,client_database
,verification_router
,verification_success_prompt_builder
,verification_success_llm
,verification_success_answer_builder
,verification_fail_prompt_builder
,verification_fail_adapter
,verification_fail_answer_builder
- User verification: Verifies the information the customer provided against a Snowflake database. Then, it either confirms their identity or asks for correct information.
- Sentiment analysis: Reads the customer's messages to understand their mood and adjusts the conversation tone accordingly.
Components involved:
sentiment_prompt_builder
,sentiment_llm
,sentiment_answer_builder
- Information extraction: Focuses on details about the customer's financial situation, such as when they can pay or how much they can afford.
Components involved:
info_extract_prompt_builder
,info_extract_llm
,info_extract_answer_builder
- Negotiation logic: Handles discussions about payment options and tries to find solutions that work for both the bank and the customer.
Components involved:
negotiation_prompt_builder
,negotiation_llm
,negotiation_answer_builder
- Payment handling: Processes the actual payment arrangements and provides payment links.
Components involved:
payment_prompt_builder
,payment_llm
,payment_answer_builder
- Escalation: Handles situations where a human needs to take over and ensures a smooth handoff to human support.
Components involved:
escalation_prompt_builder
,escalation_llm
,escalation_answer_builder
- Start call: Creates the initial greeting and asks for verification information.
Pipeline YAML
components:
root_prompt_builder:
type: haystack.components.builders.prompt_builder.PromptBuilder
init_parameters:
template: |-
You are part of a chatbot. You receive a question (Current Question) and a chat history.
Analyze the following chat history between a client and deepset bank and decide the most appropriate action to take next.
The response may include indications of the client's sentiment, willingness to pay, or specific details about their financial situation.
Based on the chat history, select one of the following actions as the next step in the process:
Start: If the client has not been authenticated. This should always be the first step.
User Verification: If the client provides their first name, last name and account number for verification.
Sentiment Analysis: If sentiment cues (e.g., frustration, relief) need to be evaluated to guide the negotiation tone.
Information Extraction: If specific financial details (e.g., the ability to pay, amount, timing, or payment preferences) need to be identified.
Negotiation Logic: If the client shows willingness to negotiate or requests information about possible payment plans.
Payment Handling: If the client agrees to make a payment immediately.
Escalation & Handoff: If the client expresses frustration, asks for human assistance, or the conversation has not progressed.
Your answer must be one of the following actions:
- Start Call
- User Verification
- Sentiment Analysis
- Information Extraction
- Negotiation Logic
- Payment Handling
- Escalation & Handoff
Context: {{ question }}
Next action:
root_llm:
type: haystack.components.generators.openai.OpenAIGenerator
init_parameters:
api_key:
type: env_var
env_vars:
- OPENAI_API_KEY
strict: false
model: "gpt-4o"
generation_kwargs:
max_tokens: 650
temperature: 0.0
seed: 0
conditional_router: # Conditional router to determine the next action based on the client's response
type: haystack.components.routers.conditional_router.ConditionalRouter
init_parameters:
routes:
- condition: '{{replies[0].lower() == ''start call''}}'
output: '{{ question }}'
output_name: call
output_type: str
- condition: '{{replies[0].lower() == ''user verification''}}'
output: '{{ question }}'
output_name: verification
output_type: str
- condition: '{{replies[0].lower() == ''sentiment analysis''}}'
output: '{{ question }}'
output_name: sentiment
output_type: str
- condition: '{{replies[0].lower() == ''negotiation logic''}}'
output: '{{ question }}'
output_name: negotiation
output_type: str
- condition: '{{replies[0].lower() == ''escalation & handoff''}}'
output: '{{ question }}'
output_name: escalation
output_type: str
- condition: '{{replies[0].lower() == ''information extraction''}}'
output: '{{ question }}'
output_name: extract
output_type: str
- condition: '{{replies[0].lower() == ''payment handling''}}'
output: '{{ question }}'
output_name: payment
output_type: str
unsafe: false
# Components for initiating the call
initiate_call_prompt_builder:
type: haystack.components.builders.prompt_builder.PromptBuilder
init_parameters:
template: |-
You are a chatbot calling a client to verify their account numbers before discussing missed auto loan payments.
Your name is Deepset, and you work for Deepset Bank as a customer service agent.
Instructions:
- Your role is to generate a prompt asking the client to verify their first and last name, along with their account number.
- This is a one-way discussion; the only questions should be to verify the account number and the client’s first and last name.
- Make sure you sound as human as possible when generating the prompt.
{{ question }}
initiate_call_llm:
type: haystack.components.generators.openai.OpenAIGenerator
init_parameters:
model: "gpt-4o"
generation_kwargs:
max_tokens: 1000
temperature: 0.0
seed: 0
initiate_call_answer_builder:
type: deepset_cloud_custom_nodes.augmenters.deepset_answer_builder.DeepsetAnswerBuilder
init_parameters:
reference_pattern: acm
# Authentification components
verification_prompt_builder:
type: haystack.components.builders.prompt_builder.PromptBuilder
init_parameters:
template: |-
You are an SQL expert. Your task is to extract the client's first name, last name, and account number from the following text {{ text }}. After identifying the name and account number, add them to the WHERE clause in the SQL template below. If you cannot identify the client's name in this text, respond with an empty string "". Your only goal is to provide the SQL template with the appropriate name or an empty string without any explanation.
SQL template:
SELECT * FROM CAR_LOAN_DB.WRITEOFF.CUSTOMERS
WHERE CLIENT_NAME = <add name here>
AND ACCOUNT_NUMBER = <add account number here>
LIMIT 1;
You must provide only the SQL query in plain text, as non-SQL characters will break the database.
Your answer must not include ```sql or ```. If you cannot identify the client in this text, respond with an empty string "".
verification_llm:
type: haystack.components.generators.openai.OpenAIGenerator
init_parameters:
model: "gpt-4o"
generation_kwargs:
max_tokens: 1000
temperature: 0.0
seed: 0
client_database: # This is meant to access client information stored in Snowflake, from which the LLM will verify the information that the customer provided.
type: deepset_cloud_custom_nodes.retrievers.snowflake_retriever.DeepsetSnowflakeRetriever
init_parameters:
user: "<snowflake-user-identifier>"
account: "<snowflake-account-identifier>"
warehouse: "<snowflake-warehouse-name>"
verification_success_adapter:
type: haystack.components.converters.output_adapter.OutputAdapter
init_parameters:
template: '{{ replies[0] }}'
output_type: str
verification_router:
type: haystack.components.routers.conditional_router.ConditionalRouter
init_parameters:
routes:
- condition: '{{ dataframe.shape[0] == 0 }}'
output: '{{ table }}'
output_name: fail
output_type: str
- condition: '{{ dataframe.shape[0] > 0 }}'
output: '{{ table }}'
output_name: success
output_type: str
unsafe: false
verification_fail_prompt_builder:
type: haystack.components.builders.prompt_builder.PromptBuilder
init_parameters:
template: |-
I'm sorry, but I couldn't find a match for your first name, last name, and account number in our system.
Could you please double-check the information and provide it again? This will help us ensure we're connecting to the correct account.
Thank you for your patience!
{{ table }}
verification_fail_adapter:
type: haystack.components.converters.output_adapter.OutputAdapter
init_parameters:
template: '{{ [prompt] }}'
output_type: typing.List[str]
verification_success_prompt_builder:
type: haystack.components.builders.prompt_builder.PromptBuilder
init_parameters:
template: |-
You are a customer service agent at Deepset Bank responsible for negotiating auto loan payments with clients who have missed their payments.
Your task is to verify client details against the bank's records and start the discussion around paying the missed car loan payments.
Use the chat history below for guidance and context.
Instructions:
- Verify the user's identity by confirming their first name, last name, and account number.
- Extract critical financial information from the table and ask the user if they would like to make the missed payment.
- Provide them with an update on their loan, including details about the car, the loan amount, and the remaining balance to pay off the loan.
- Remember, the generated prompt will be used for a text-to-speech system, so you should sound like a human.
It's important to consider that the client you are discussing with has missed their payment.
Bank's records: {{ table }}
Chat history: {{ question }}
Prompt:
verification_success_llm:
type: haystack.components.generators.openai.OpenAIGenerator
init_parameters:
model: "gpt-4o"
generation_kwargs:
max_tokens: 2000
temperature: 0.0
seed: 0
verification_fail_answer_builder:
type: deepset_cloud_custom_nodes.augmenters.deepset_answer_builder.DeepsetAnswerBuilder
init_parameters:
reference_pattern: acm
verification_success_answer_builder:
type: deepset_cloud_custom_nodes.augmenters.deepset_answer_builder.DeepsetAnswerBuilder
init_parameters:
reference_pattern: acm
verification_answer_builder_joiner:
type: haystack.components.joiners.answer_joiner.AnswerJoiner
init_parameters: {}
# Components for detecting clients' sentiment
sentiment_prompt_builder:
type: haystack.components.builders.prompt_builder.PromptBuilder
init_parameters:
template: |-
You are a customer service agent at Deepset Bank responsible for negotiating auto loan payments with clients who have missed their payments.
You have been provided with the chat history and the client's current question below to help you achieve your goal.
Instructions:
- Analyze the client's response in the chat history for emotional cues.
- Assess whether the sentiment is positive, neutral, or negative, and determine if the client is receptive, resistant, frustrated, or cooperative regarding commitment to payment or a payment arrangement.
Remember, the generated prompt will be used for a text-to-speech system, so you should sound like a human.
It's important to consider that the client you are discussing with has missed their payment.
It is also important to remember that you are already on the call with the client.
The chat history below refers to the previous conversation. That said, do not act as if this is the first time you are talking to the client.
{{ question }}
Prompt:
sentiment_llm:
type: haystack.components.generators.openai.OpenAIGenerator
init_parameters:
model: "gpt-4o"
generation_kwargs:
max_tokens: 2000
temperature: 0.0
seed: 0
sentiment_answer_builder:
type: deepset_cloud_custom_nodes.augmenters.deepset_answer_builder.DeepsetAnswerBuilder
init_parameters:
reference_pattern: acm
# components for conducting the payment negotiation
negotiation_prompt_builder:
type: haystack.components.builders.prompt_builder.PromptBuilder
init_parameters:
template: |-
You are a customer service agent at Deepset Bank responsible for negotiating auto loan payments with clients who have missed their payments.
You have been provided with the chat history and the client's current question below to help you achieve your goal.
Instructions:
- Generate a response based on the client’s sentiment and willingness to discuss payment options, aiming to reach a mutually agreeable payment solution.
- Adjust your tone according to the client’s responses. The response should maintain a respectful tone and be solution-oriented, encouraging the client toward a payment commitment that meets their current capacity.
It's important to consider that the client you are discussing with has missed their payment.
Remember that you are already on the call with the client. The chat history below refers to the previous conversation, so do not act as if this is the first time you are talking to the client.
{{ question }}
Prompt:
negotiation_llm:
type: haystack.components.generators.openai.OpenAIGenerator
init_parameters:
model: "gpt-4o"
generation_kwargs:
max_tokens: 2000
temperature: 0.0
seed: 0
negotiation_answer_builder:
type: deepset_cloud_custom_nodes.augmenters.deepset_answer_builder.DeepsetAnswerBuilder
init_parameters:
reference_pattern: acm
# Components for escalations and handoffs
escalation_prompt_builder:
type: haystack.components.builders.prompt_builder.PromptBuilder
init_parameters:
template: |-
You are a customer service agent at Deepset Bank responsible for negotiating auto loan payments with clients who have missed their payments.
You have been provided with the chat history and the client current question below to help you achieve your goal.
Instructions:
- The client’s response suggests they may need additional assistance from a human representative.
- Based on the tone of their message (e.g., frustration, confusion, or request for direct help), generate a response that politely acknowledges their concerns and reassures them that they will be connected with a team member who can help.
- Ensure the message conveys empathy and appreciation for their patience, maintaining a supportive and professional tone during the handoff."
Example response:
"Thank you for your patience, [Client’s Name].
I understand that this might be a bit complex, so I’m connecting you with a team member who can assist further.
We appreciate you working with us, and someone will be with you shortly to make sure your concerns are addressed."
It's important to consider that the client you are in discussion with has missed their payment.
It is also important to remember that you are already on the call with the client. The chat history below refers to the previous conversation. That said, do not act as if this is the first time you are talking to the client.
{{ question }}
Prompt:
escalation_llm:
type: haystack.components.generators.openai.OpenAIGenerator
init_parameters:
model: "gpt-4o"
generation_kwargs:
max_tokens: 2000
temperature: 0.0
seed: 0
escalation_answer_builder:
type: deepset_cloud_custom_nodes.augmenters.deepset_answer_builder.DeepsetAnswerBuilder
init_parameters:
reference_pattern: acm
# Components for extracting relevant financial details
info_extract_prompt_builder:
type: haystack.components.builders.prompt_builder.PromptBuilder
init_parameters:
template: |-
You are a customer service agent at Deepset Bank, responsible for negotiating auto loan payments with clients who have missed their payments.
You have been provided with the chat history and the client's current question below to help you achieve your goal.
Instructions:
- Analyze the client’s response and extract relevant financial details that can guide the negotiation process.
- Look for information such as the client's ability or willingness to pay, along with specific payments.
It is important to consider that the client you are discussing with has missed their payment. It is also essential to remember that you are already on the call with the client.
The chat history below refers to the previous conversation. That said, do not act as if this is the first time you are talking to the client.
Example of extracted information: "The client indicated they can make a partial payment of $100 next week but cannot commit to the full balance at this time."
{{ question }}
Prompt:
info_extract_llm:
type: haystack.components.generators.openai.OpenAIGenerator
init_parameters:
model: "gpt-4o"
generation_kwargs:
max_tokens: 2000
temperature: 0.0
seed: 0
info_extract_answer_builder:
type: deepset_cloud_custom_nodes.augmenters.deepset_answer_builder.DeepsetAnswerBuilder
init_parameters:
reference_pattern: acm
# Component for handling the payment
payment_prompt_builder:
type: haystack.components.builders.prompt_builder.PromptBuilder
init_parameters:
template: |-
You are a customer service agent at deepset Bank responsible for negotiating auto loan payments with clients who have missed their payments.
You have been provided with the chat history and the client current question below to help you achieve your goal.
Instructions:
- Based on the client’s agreement to make a payment or partial payment, generate a message that confirms their willingness and provides instructions for completing the payment.
- If they have chosen a specific payment plan, outline the details clearly. Include a secure payment link, and thank the client for their cooperation.
- Ensure the tone is positive and appreciative, encouraging a smooth completion of the payment process."
Payment Link: "https://www.deepset.ai"
Example response:
"Thank you for your cooperation, [Client’s Name]! You can complete your payment by following this secure link: [Payment Link]. If you have any questions, please let us know—we’re here to help!”
It is also important to remember that you are already on the call with the client.
The chat history below refers to the previous conversation. That said, do not act as if this is the first time you are talking to the client.
{{ question }}
Prompt:
payment_llm:
type: haystack.components.generators.openai.OpenAIGenerator
init_parameters:
model: "gpt-4o"
generation_kwargs:
max_tokens: 2000
temperature: 0.0
seed: 0
payment_answer_builder:
type: deepset_cloud_custom_nodes.augmenters.deepset_answer_builder.DeepsetAnswerBuilder
init_parameters:
reference_pattern: acm
answer_joiner:
type: haystack.components.joiners.answer_joiner.AnswerJoiner
init_parameters: {}
connections:
- sender: root_prompt_builder.prompt
receiver: root_llm.prompt
- sender: root_llm.replies
receiver: conditional_router.replies
- sender: conditional_router.call
receiver: initiate_call_prompt_builder.question
- sender: initiate_call_prompt_builder.prompt
receiver: initiate_call_llm.prompt
- sender: initiate_call_llm.replies
receiver: initiate_call_answer_builder.replies
- sender: conditional_router.call
receiver: initiate_call_answer_builder.query
- sender: conditional_router.verification
receiver: verification_prompt_builder.text
- sender: verification_prompt_builder.prompt
receiver: verification_llm.prompt
- sender: verification_llm.replies
receiver: verification_success_adapter.replies
- sender: verification_success_adapter.output
receiver: client_database.query
- sender: client_database.table
receiver: verification_router.table
- sender: verification_router.fail
receiver: verification_fail_prompt_builder.table
- sender: verification_fail_prompt_builder.prompt
receiver: verification_fail_adapter.prompt
- sender: verification_fail_adapter.output
receiver: verification_fail_answer_builder.replies
- sender: client_database.dataframe
receiver: verification_router.dataframe
- sender: verification_router.fail
receiver: verification_fail_answer_builder.query
- sender: verification_router.success
receiver: verification_success_prompt_builder.table
- sender: verification_success_prompt_builder.prompt
receiver: verification_success_llm.prompt
- sender: verification_success_llm.replies
receiver: verification_success_answer_builder.replies
- sender: verification_router.success
receiver: verification_success_answer_builder.query
- sender: verification_success_answer_builder.answers
receiver: verification_answer_builder_joiner.answers
- sender: verification_fail_answer_builder.answers
receiver: verification_answer_builder_joiner.answers
- sender: conditional_router.sentiment
receiver: sentiment_prompt_builder.question
- sender: sentiment_prompt_builder.prompt
receiver: sentiment_llm.prompt
- sender: sentiment_llm.replies
receiver: sentiment_answer_builder.replies
- sender: conditional_router.sentiment
receiver: sentiment_answer_builder.query
- sender: conditional_router.negotiation
receiver: negotiation_prompt_builder.question
- sender: negotiation_prompt_builder.prompt
receiver: negotiation_llm.prompt
- sender: negotiation_llm.replies
receiver: negotiation_answer_builder.replies
- sender: conditional_router.negotiation
receiver: negotiation_answer_builder.query
- sender: conditional_router.escalation
receiver: escalation_prompt_builder.question
- sender: escalation_prompt_builder.prompt
receiver: escalation_llm.prompt
- sender: escalation_llm.replies
receiver: escalation_answer_builder.replies
- sender: conditional_router.escalation
receiver: escalation_answer_builder.query
- sender: conditional_router.extract
receiver: info_extract_prompt_builder.question
- sender: info_extract_prompt_builder.prompt
receiver: info_extract_llm.prompt
- sender: info_extract_llm.replies
receiver: info_extract_answer_builder.replies
- sender: conditional_router.escalation
receiver: info_extract_answer_builder.query
- sender: conditional_router.payment
receiver: payment_prompt_builder.question
- sender: payment_prompt_builder.prompt
receiver: payment_llm.prompt
- sender: payment_llm.replies
receiver: payment_answer_builder.replies
- sender: conditional_router.payment
receiver: payment_answer_builder.query
- sender: verification_answer_builder_joiner.answers
receiver: answer_joiner.answers
- sender: initiate_call_answer_builder.answers
receiver: answer_joiner.answers
- sender: sentiment_answer_builder.answers
receiver: answer_joiner.answers
- sender: negotiation_answer_builder.answers
receiver: answer_joiner.answers
- sender: escalation_answer_builder.answers
receiver: answer_joiner.answers
- sender: info_extract_answer_builder.answers
receiver: answer_joiner.answers
- sender: payment_answer_builder.answers
receiver: answer_joiner.answers
max_runs_per_component: 100
metadata: {}
inputs: # Define the inputs for your pipeline
query: # These components will receive the query as input
- "conditional_router.question"
- "root_prompt_builder.question"
- "verification_success_prompt_builder.question"
outputs: # Defines the output of your pipeline
answers: "answer_joiner.answers" # The output of the pipeline is the generated answers
indexing_yaml: |
# If you need help with the YAML format, have a look at https://docs.cloud.deepset.ai/v2.0/docs/create-a-pipeline#create-a-pipeline-using-pipeline-editor.
# This section defines components that you want to use in your pipelines. Each component must have a name and a type. You can also set the component's parameters here.
# The name is up to you, you can give your component a friendly name. You then use components' names when specifying the connections in the pipeline.
# Type is the class path of the component. You can check the type on the component's documentation page.
# NOTE: The query pipeline does not make use of the document store, as it only makes a call to GPT-4o.
# However, an indexing pipeline is nonetheless required.
components:
file_classifier:
type: haystack.components.routers.file_type_router.FileTypeRouter
init_parameters:
mime_types:
- text/plain
text_converter:
type: haystack.components.converters.txt.TextFileToDocument
init_parameters:
encoding: utf-8
writer:
type: haystack.components.writers.document_writer.DocumentWriter
init_parameters:
document_store:
type: haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore
init_parameters:
embedding_dim: 768
similarity: cosine
policy: OVERWRITE
connections: # Defines how the components are connected
- sender: file_classifier.text/plain
receiver: text_converter.sources
- sender: text_converter.documents
receiver: writer.documents
inputs: # Define the inputs for your pipeline
files: "file_classifier.sources" # This component will receive the files to index as input
Updated 15 days ago
Related Links