https://retellai.com/?utm_source=discord&utm_medium=seo logo
I asked my agent about a course name and it correc...
# ❓・ai-evy-support
a
@AI Evy I asked my agent about a course name and it correctly called the tool to get the course information but then I asked about a different course name and it didn't even check the course schedule even though it seemed to be aware that that was a course name. How do I make sure that it's always checking the course schedule and getting that tool called? https://cdn.discordapp.com/attachments/1302816169367044149/1488189609132425297/image.png?ex=69cbe014&is=69ca8e94&hm=d3ad68a66a2f82daf9f8a92aa1c428c81f9658e82fe1a34bb1230c42821db739&
a
Thanks for tagging me @Anthony. I'll look through relevant sources and get back to you shortly.
### Answer To ensure your agent consistently calls the tool for course information, you need to refine your prompt engineering. The key is making the tool-calling behavior explicit and mandatory in your agent's instructions [(1) ]() . Recommended approaches: 1. Add explicit tool-calling instructions in your prompt: In your agent's prompt, include clear directives like:
Copy code
When a user mentions any course name or asks about course information, you MUST call the get_course_schedule tool before responding. Always verify course details by calling the tool, even if you think you know the answer.
2. Use structured prompts with a dedicated section for tool usage: Break your prompt into sections following best practices. Add a "Tool Usage Guidelines" section:
Copy code
## Tool Usage Guidelines
- ALWAYS call get_course_schedule when a course name is mentioned
- Call the tool BEFORE providing any course-specific information
- If unsure whether something is a course name, call the tool to verify
3. If using Conversation Flow agents: Consider using Conversation Flow to create more predictable tool-calling behavior. You can design specific nodes where the tool call is mandatory before transitioning to the next node [(1) ]() [(2) ]() . 4. Improve your tool description: Make sure your tool's description clearly indicates when it should be called. The description helps the LLM understand when to invoke the tool [(1) ]() . Additional consideration: If you're using a multi-prompt or conversation flow setup, ensure each relevant node or state has access to the tool and includes instructions to use it [(1) ]() [(3) ]() .
​ To learn more, see the sources I considered: [[1] Prompt Engineering Guide](https://docs.retellai.com/build/prompt-engineering-guide) [[2] How to Deploy Conversational AI | Retell AI](https://www.retellai.com/blog/how-to-deploy-conversational-ai) [[3] Training & Customizing AI Voice Agents | Retell AI](https://www.retellai.com/blog/training-and-customizing-voice-agents-with-retell-ai) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
@AI Evy It looks like it didn't move from this node to call the tool again even though I have a specific prompt for if a user asks about a course https://cdn.discordapp.com/attachments/1488189609316716588/1488190075337572534/image.png?ex=69cbe083&is=69ca8f03&hm=9aeba3bbfc0163beb22a80b03b071477c9e5472ed9e191d53e0e30b0fe6e5ce5&
a
Thanks for the follow-up, @Anthony. I'll get back to you soon.
### Answer If your agent isn't transitioning to call the tool again when a user asks about another course, there are several debugging approaches to try: 1. Use the LLM Playground Debug Flow When a node doesn't behave as expected in Conversation Flow agents, use the LLM Playground debug tools and apply one of these fixes [(1) ]() : - Add fine-tuning conversation examples if the response itself is off - Add transition fine-tune examples if the node is not transitioning when it should (e.g., after a tool result) - Split the node into multiple nodes so each node has simpler, more deterministic behavior - Adjust LLM temperature and use "Regenerate 10 Times" to test consistency 2. Tighten Your Tool-Calling Prompt Instructions For Single/Multi Prompt agents, give explicit trigger conditions for each tool in the system prompt, not just a vague description [(2) ]() . If your tools used to be called and suddenly aren't, the LLM may no longer be reliably inferring when to call them from a weak description [(1) ]() . Strengthen the "Tool Usage Instructions" section with clear "call TOOL_X when…" rules and exact tool names [(2) ]() [(1) ]() . 3. Verify Your Transition Logic If you're using Conversation Flow, confirm that: - The tool is properly configured as a Tool in the current node [(3) ]() - Your transition conditions are correctly set to move to the next node after the tool executes - You haven't accidentally made the tool "Option
al" when it should be required 4. Consider Separating Functions into Different States Create a dedicated state for your course lookup tool that transitions to the next state after execution. This ensures the tool executes before moving forward . If the issue persists after trying these approaches, you may want to share your call ID or agent ID for more specific troubleshooting.
​ To learn more, see the sources I considered: [[1] Tools not being triggered](https://community.retellai.com/t/tools-not-being-triggered/201) [[2] Prompt Engineering Guide](https://docs.retellai.com/build/prompt-engineering-guide) [[3] Custom function not executing despite being configured as tool in state](https://community.retellai.com/t/custom-function-not-executing-despite-being-configured-as-tool-in-state/705) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
@User How do I make sure that the agent confirms the name of the course before it responds with what it thinks the course name is? Because right now it will just guess without actually confirming. See my prompt below. In my tool call under the tool instructions, I instruct it to use fuzzy matching to try and guess the name of the course based on what it has there. Obviously in my prompt instructions I tell it to confirm the course name before it actually gives any course information # Retrieval Priority (Critical Rule): - When answering about classes, only use massage styles and course names that appear under the following sections: - "## Massage Classes" - " #### Required Courses" - "#### Additional Massage Curriculum" - "## Massage Courses General Info" - "### Massage Electives" - If the course name a user says does not match any course names in your list, make your best attempt to match what the user said with the course names you have from the "GetCourseSchedule" list, but confirm with the user if you're correct on your name guess before proceeding. Only once the user has confirmed the course you mentioned is the one they were asking about should you provide information on that course. - Example: User: "When is the next LEMS 3 class?" Agent: "Sorry, I don't see a class with that name in my list, did you mean Lymph 3?" User: "Yes, that one" - Do not refer to classes by names other than the names as they are written exactly in your list from the "GetCourseSchedule" tool - If the user references a course that has multiple listed types, such as Esalen (Example 1: "Esalen Massage", "Intro to Esalen", Example 2: "“Just…” Series: Shoulders", "“Just… Condition to Solution” Series: Sciatica"), confirm with the user which course they meant before providing information. https://cdn.discordapp.com/attachments/1488189609316716588/1488193994340045011/image.png?ex=69cbe429&is=69ca92a9&hm=a594ce734b7351b537bff13d36f197593bf6ffede5704f61e71459259689283b&
@AI Evy How do I make sure that the agent confirms the name of the course before it responds with what it thinks the course name is? Because right now it will just guess without actually confirming. See my prompt below. In my tool call under the tool instructions, I instruct it to use fuzzy matching to try and guess the name of the course based on what it has there. Obviously in my prompt instructions I tell it to confirm the course name before it actually gives any course information # Retrieval Priority (Critical Rule): - When answering about classes, only use massage styles and course names that appear under the following sections: - "## Massage Classes" - " #### Required Courses" - "#### Additional Massage Curriculum" - "## Massage Courses General Info" - "### Massage Electives" - If the course name a user says does not match any course names in your list, make your best attempt to match what the user said with the course names you have from the "GetCourseSchedule" list, but confirm with the user if you're correct on your name guess before proceeding. Only once the user has confirmed the course you mentioned is the one they were asking about should you provide information on that course. - Example: User: "When is the next LEMS 3 class?" Agent: "Sorry, I don't see a class with that name in my list, did you mean Lymph 3?" User: "Yes, that one" - Do not refer to classes by names other than the names as they are written exactly in your list from the "GetCourseSchedule" tool - If the user references a course that has multiple listed types, such as Esalen (Example 1: "Esalen Massage", "Intro to Esalen", Example 2: "“Just…” Series: Shoulders", "“Just… Condition to Solution” Series: Sciatica"), confirm with the user which course they meant before providing information. https://cdn.discordapp.com/attachments/1488189609316716588/1488194197461930125/image.png?ex=69cbe459&is=69ca92d9&hm=8b1ab54f69de70b7d7faba88a0639867c37adcd894d67dde47a9d37119c809f0&
a
Thanks for the follow-up, @Anthony. I'll get back to you soon.
### Answer Your prompt has the right idea, but the issue is that LLMs often struggle to follow multi-step conditional logic reliably, especially when it involves calling a tool, evaluating the result, and then deciding whether to confirm before proceeding [(1) ]() . Here are specific improvements to make your confirmation behavior more reliable: 1. Restructure your prompt to separate the confirmation step more clearly Instead of embedding the confirmation logic within a complex conditional, create a two-phase approach in your prompt :
Copy code
## Tool Usage Instructions

1. When a user asks about a course:
   - FIRST: Call the GetCourseSchedule tool with the course name the user mentioned
   - SECOND: Evaluate the tool result

2. After calling GetCourseSchedule:
   - If the tool returns an EXACT match: Proceed to provide course information
   - If the tool returns a FUZZY match or suggested alternative: 
     * DO NOT provide course information yet
     * Ask the user: "I don't see [user's course name] in my list. Did you mean [matched course name]?"
     * WAIT for user confirmation
   - If the tool returns NO match: Tell the user you cannot find that course

3. Only provide course details AFTER:
   - An exact match was found, OR
   - The user has confirmed the suggested course name
2. Move the fuzzy matching logic OUT of the tool and INTO the prompt Your current setup has fuzzy matching in the tool instructions, which means the tool is making the guess. Instead, have the tool return both exact matches AND potential alternatives, then let the agent's prompt decide what to do with them . 3. If using Conversation Flow, create separate states Consider using Conversation Flow to enforce this behavior deterministically : - **State 1**: Call the course lookup tool - **State 2**: If fuzzy match, ask for confirmation (transition only after user confirms) - **State 3**: Provide course information 4. Add explicit examples in your prompt The prompt engineering guide emphasizes using concrete examples . Expand your example section:
Copy code
## Confirmation Examples

Example 1 - Fuzzy Match:
User: "When is the next LEMS 3 class?"
Agent: "I don't see a class called 'LEMS 3' in my schedule. Did you mean 'Lymph 3'?"
User: "Yes, that one"
Agent: [NOW provide Lymph 3 information]

Example 2 - Multiple Matches:
User: "Tell me about Esalen"
Agent: "I have several Esalen courses: 'Esalen Massage' and 'Intro to Esalen'. Which one are you interested in?"
User: "The intro one"
Agent: [NOW provide Intro to Esalen information]

Example 3 - Exact Match:
User: "When is Lymph 3?"
Agent: [Directly provide Lymph 3 information since it's an exact match]
5. Use stricter language in your instructions Replace "confirm with the user if you're correct" with more explicit directives :
Copy code
CRITICAL: You MUST NOT provide course details until:
- The course name is an exact match, OR
- You have asked "Did you mean [course name]?" AND the user has replied affirmatively

If you provide course information without confirmation on a fuzzy match, you have failed your task.
​ To learn more, see the sources I considered: [[1] Prompt Engineering Guide](https://docs.retellai.com/build/prompt-engineering-guide) ​
The key issue is that your current prompt relies on the agent to correctly interpret and follow a complex conditional flow. Breaking it into explicit, sequential steps with clear examples makes it much more reliable .
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
@AI Evy here is the result. is there a better way to have it fuzzy match based on phonetics? it should have inferred that "SLM" sounds like Esalen https://cdn.discordapp.com/attachments/1488189609316716588/1488195110112854067/image.png?ex=69cbe533&is=69ca93b3&hm=09d7fff89da28d07fd26458f897b203e2ca5d479e72c40cad2c3df8eeaa1b181&
a
Thanks for the follow-up, @Anthony. I'll get back to you soon.
### Answer Based on the available sources, I don't have specific documentation about phonetic matching capabilities in Retell AI's fuzzy matching logic. However, I can suggest several approaches to improve matching for cases like "SLM" → "Esalen": 1. Use Boosted Keywords for ASR accuracy The transcription issue you're experiencing ("SLM" instead of "Esalen") may be an ASR (speech-to-text) problem rather than a fuzzy matching issue [(1) ]() . Add "Esalen" and similar course names to your agent's Boosted Keywords settings to bias the speech recognition toward recognizing these specific terms correctly . 2. Implement phonetic matching in your tool logic Since Retell AI's Code Tool allows you to write JavaScript directly in the agent [(2) ]() , you could implement phonetic matching logic there:
Copy code
javascript
// Example: Add phonetic aliases for course names
const phoneticAliases = {
  "SLM": "Esalen",
  "esalen": "Esalen",
  "eslm": "Esalen"
  // Add more phonetic variations
};

const userInput = dv.course_name.toLowerCase() ;
const matchedCourse = phoneticAliases[userInput] || userInput;

return { matched_course: matchedCourse };
3. Provide explicit phonetic examples in your prompt Add common phonetic mishearings to your prompt instructions to help the LLM recognize patterns [(3) ]() :
Copy code
## Common Course Name Variations
- "SLM" or "eslm" → Ask: "Did you mean Esalen?"
- "LEMS" → Ask: "Did you mean Lymph?"
- [Add other common mishearings]
4. Adjust your confirmation strategy Instead of relying solely on fuzzy matching after transcription, structure your prompt to proactively offer clarification when confidence is low :
Copy code
When a course name seems unclear or abbreviated:
- Offer the 2-3 most phonetically similar course names
- Ask: "I heard [what was transcribed]. Did you mean [Option 1], [Option 2], or something else?"
The root issue appears to be ASR transcription quality rather than the matching algorithm itself. Boosted Keywords is your best first step to improve how "Esalen" is heard and transcribed [(1) ]() .
​ To learn more, see the sources I considered: [[1] Transcriptions doesn't match with the audio, very poor quality stt.](https://discord.com/channels/1186424376300679209/1430808810016079953) [[2] Code Tool](https://docs.retellai.com/build/single-multi-prompt/code-tool) [[3] Prompt Engineering Guide](https://docs.retellai.com/build/prompt-engineering-guide) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.