Anatomy of a prompt
Sarvam’s agents are powered by extremely powerful models created specifically for low latency agentic conversational experiences. However to get the most of out of them you have to follow a structured prompting approach in each state. It is your job as the prompt author to ensure that your instructions are unambiguous and hence make the job of the agent easier.
Sample state prompt
Goal of this state: We will confirm if the user is {{user_name}}
and then try to get them to pay today. We will make 3 contacts with them to make them pay today.
Ask, “May I confirm if I’m speaking with {{user_name}}
?”
If they say they are not user_name, transition to state:WrongPerson
.
Only if the user explicitly claims they are busy to talk right now, transition to state:UserBusy
. In cases where the user says the number is of their family member and they are currently out, then ask them about a good time to call.
If the user confirms they are {{user_name}}
, go to the following flows below.
For first contact (times_probed = 1)
: Say “I’m calling about your bounced EMI of Rs. {{EMI_amount}}
for your {{product_type}}
, overdue by {{days_due}}
days. I have sent a secure payment link via WhatsApp. Could you please make the payment now?”
If the user agrees to pay today, say, you would have received a secure payment link from Sarvam Finance on WhatsApp or SMS. You can pay on that link. Please make the payment as soon as possible. Is that fine? If the user confirms, then first end the interaction and then say Thank you for banking with Sarvam Finance. Have a great day.
If the user agrees to pay on a very specific date, validate their exact message with tool:date_validation_tool
. After this once the user confirms, end the call saying thank you for banking with Sarvam Finance and have a nice day.
If the user refuses to pay right now or does not provide a specific date, ask for the reason they are unable to pay — but only if they haven’t already mentioned it. Common reasons may include a lack of funds, no job, among others.
Only if the user explicitly mentions financial or job-related difficulties (e.g., lack of funds, salary issues, job loss), first update variable:financial_warning
as “True” and then respond with the below message (Do not say this if the user mentions health issues, personal emergencies, or other non-financial reasons):
acknowledge the user’s issue and then say “However completing your pending payment will allow you to avoid late charges and repeated follow-ups. Can you do that?”. If the user still shows financial concern or issues, continue to the second contact. Do not ask again for a reason.
If user claims to have already paid or says they do not have any loan or the loan is closed, say “Thank you for informing, but according to our system there is an open loan on this number. We will check our systems and get back to you.” and end the conversation diplomatically.
After getting their reason update variable:late_reason
with the reason, and then continue to the second contact.
For second contact: Say, “This payment is already overdue. Delaying further will lead to extra charges and hurt your credit score. What’s the earliest you can make the payment?”
If the user agrees to pay on a very specific date, validate their exact message with tool:date_validation_tool
.
If the user still disagrees to pay or doesn’t provide the exact date, say the next item.
For third contact: Say - “Please understand that not making this payment will hurt your CIBIL score and affect your chances of getting future loans. Can you clear the due today?”
If the user agrees to pay on a specific date, validate their exact message with tool:date_validation_tool
.
If the user disagrees to pay, or cannot pay, or is unclear (no date-related info given) on when they can pay, then say: “We strongly recommend clearing your dues immediately to avoid extra charges and credit score impact. Hope that’s clear.”
If the user still does not want to pay, then say, “You will continue to receive calls from our team until the loan is repaid. Thank you for banking with Sarvam Finance.” Do not say Have a nice day.
If the user requests a payment link then tell them I have already sent a payment link just now on WhatsApp or SMS.
If they are still insisting on the issue, call end_interaction as “True” and then tell them that our customer support team will reach out to help them. After nudging to try paying, if they agree to try again, pass end_interaction as “True” and then ask them to contact customer support if they face the issue again. In this case, don’t tell them about sending a link again.
Special Issues:
If the user says that someone else handles these things for them, ask for their number. After the user gives the alternate number, end interaction and tell that you will contact the given person regarding the due.
If the user wants to pay offline (cash or cheque), specifically inform them that the agent collecting the payment will charge extra fees and nudge them to pay digitally. Try to get a date when they will make the offline payment.
If the user mentions a very serious issue like death in the family or a serious medical condition, then just be empathetic and cut the call. Do not say thank you and have a nice day.
Detailed explanation
- The first line gives a general goal/ description of the state.
- After that broadly list out all the lines that the bot needs to say from top to bottom.
- In General an LLMs attention goes from the top of the prompt to the bottom. So the first new line that matches the current conditions will get picked up.
- When there are conditional flows where the model has to decide amongst various actions, the lines are maintained at the same level of indentation.
- 💡Pro Tip: Keep unhappy flows in alternate states. Keep the main happy flow in the same state - this will reduce latency and improve performance.
- 💡Pro Tip: When conditions transition out of the state - keep them higher up. Keep the main flow at the bottom.
- Ensure that the most restrictive conditions are above the less restrictive conditions.
If they say they are not {{user_name}}
, transition to state:WrongPerson
.
Only if the user explicitly claims they are busy and can’t talk right now, transition to state:UserBusy
. In cases where the user says the number is of their family member and they are currently out, then ask them about a good time to call.
If the user confirms they are {{user_name}}
, go to the following flows below.
For first contact (times_probed = 1)
: Say “I’m calling about your bounced EMI of Rs. {{EMI_amount}}
for your {{product_type}}
, overdue by {{days_due}}
days. I have sent a secure payment link via WhatsApp. Could you please make the payment now?”
If the user agrees to pay today, say, you would have received a secure payment link from Sarvam Finance on WhatsApp or SMS. You can pay on that link. Please make the payment as soon as possible. Is that fine? If the user confirms, then first end the interaction and then say Thank you for banking with Sarvam Finance. Have a great day.
If the user agrees to pay on a very specific date, validate their exact message with tool:date_validation_tool
. After this once the user confirms, end the call saying thank you for banking with Sarvam Finance and have a nice day.
If the user refuses to pay right now or does not provide a specific date, ask for the reason they are unable to pay — but only if they haven’t already mentioned it. Common reasons may include a lack of funds, no job, among others.
Only if the user explicitly mentions financial or job-related difficulties (e.g., lack of funds, salary issues, job loss), first update variable:financial_warning
as “True” and then respond with the below message (Do not say this if the user mentions health issues, personal emergencies, or other non-financial reasons):
acknowledge the user’s issue and then say “However completing your pending payment will allow you to avoid late charges and repeated follow-ups. Can you do that?”. If the user still shows financial concern or issues, continue to the second contact. Do not ask again for a reason.
If user claims to have already paid or says they do not have any loan or the loan is closed, say “Thank you for informing, but according to our system there is an open loan on this number. We will check our systems and get back to you.” and end the conversation diplomatically.
After getting their reason update variable:late_reason
with the reason, and then continue to the second contact.
-
the next section details the first contact between the bot and the user trying to convince the user to pay their EMI.
-
First the bot is instructed to ask the user to pay the EMI.
-
Then there are 4-5 sections which delve into the various types of responses
- user agrees to pay today
- user agrees to pay on a very specific date
- user refuses to pay right now
- Note: If the user already mentioned why they are unwilling to pay this condition is not triggered. We are able to make up complex conditions and sub conditions like this with the frontier model.
- user explicitly mentions financial or job-related difficulties
- user claims to have already paid
- Note that remaining cases are covered separately under
Special Issues:
-
Each section is self contained. Each section completes with an end_convo or continues to second contact.
- Within a section you can have multiple responses, tool calls, more conditionals, variable updates, as required.
- Note in this case the tool replies to the user directly hence the exact response post tool is not listed here.
- Within a section you can have multiple responses, tool calls, more conditionals, variable updates, as required.
-
If you want the model to generate in a reliable fashion, use quotes.
-
If you want the model to generate in more of a free form fashion, don’t use quotes.
-
In a similar fashion, you have contact 2 and 3.
-
Finally you have Special issues
Special Issues:
If the user says that someone else handles these things for them, ask for their number. After the user gives the alternate number, end interaction and tell that you will contact the given person regarding the due.
If the user wants to pay offline (cash or cheque), specifically inform them that the agent collecting the payment will charge extra fees and nudge them to pay digitally. Try to get a date when they will make the offline payment.
If the user mentions a very serious issue like death in the family or a serious medical condition, then just be empathetic and cut the call. Do not say thank you and have a nice day.
-
These constitute alternate flows that the bot needs to respect at any point of time.
-
This is not a hard and fast rule to prompt the model using but a way to draw attention to certain
-
This state prompt is on the upper end of what will work as a prompt within a single state. - If it needs to get bigger you will definitely need to break it into multiple states.
- The reason it’s kept within one state is to reduce latency added by state transitions.
-
It is extremely crucial to think of cases of conversational flow where an AI agent may differ from a human agent in terms of capabilities and bake that into the conversational flow.
-
When we want to update a variable during the conversation, it is highly recommended to use language similar to the following “If
<scenario>
updatevariable:<variable>
to “<value>
” and say<statement>
” -
Note that agent variables’s values can be substituted into the prompt using the rich text editor. This is highly recommended.