https://retellai.com/?utm_source=discord&utm_medium=seo logo
<@1145576664366055464> Issue with Custom Webhoo...
# ❓・ai-evy-support
u
@AI Evy Issue with Custom Webhook Data Usage in Retell Agent Prompt I'm reaching out regarding a recurring issue I'm facing with my Retell agent setup. I’ve configured a special webhook linked to the caller’s phone number (via Inboon) that triggers a request in N8n. The webhook seems to work fine and does send the expected data to the agent before the conversation starts. However, the agent is inconsistent in how it uses or acknowledges this data. Sometimes it incorporates it into the conversation as expected, and other times it completely ignores it — as if it’s not recognizing the data provided. Here is an example of how I formatted my prompt in Identity section : [...] You help customers understand their situation based on the following information, if available: - Last Name: {{first_name}} {{last_name}} - Address: {{adr}}, {{comp_adr}}, {{postal_code}} {{city}} - Invoice Date: {{invoice_date}} - Number of interventions: {{nb_intervention}} - Warranty: {{under_warranty}} - Equipment: {{equipment_name}} (ref: {{equipment_ref}}) - Operation Type: {{operation}} [...] ### ### \[USE OF CRM DATA] If you receive the following information via the webhook that launches directly at the start of the call, use it in your response without ever saying you received it automatically. ==> IF YOU DON'T RECEIVE THE INFORMATION AT THE BEGINNING OF THE CALL VIA THE WEBHOOK, DON'T TRY TO FIND IT WITH THEIR NAME, ADDRESS, OR CUSTOMER NUMBER; IT WON'T WORK. SIMPLY LISTEN TO THEIR REQUEST AS A CUSTOMER NOT REGISTERED IN THE DATABASE. If you did not receive this data or some of it is missing: * Never say it out loud. Simply ask what their problem is, then respond according to the response logic below. Then, to write all this down, ask him for the information you're missing: * Ask the questions one by one: name, full address, model, installation date help me curated better way here
a
Thanks for tagging me @.manthu. I'll look through relevant sources and get back to you shortly.
### Answer Your issue with inconsistent dynamic variable usage is a common challenge with webhook-based personalization. Here are several strategies to improve reliability: ## Webhook Response Structure For inbound calls, ensure your webhook response includes properly formatted dynamic variables [(1) ]() . The inbound call webhook allows you to set dynamic variables that will be available throughout the call [(2) ]() . ## Prompt Engineering Best Practices Based on the training approaches used in Retell AI, consider restructuring your prompt to be more explicit about data handling [(3) ]() . Instead of relying on conditional logic within a single prompt, you could: 1. **Use explicit data validation prompts**: Start with a clear instruction that checks if the data exists before proceeding 2. **Implement fallback logic**: Create distinct conversation paths for when data is available vs. when it's missing 3. **Add data confirmation steps**: Have the agent confirm key information early in the conversation ## Dynamic Variable Implementation The inconsistency you're experiencing might be related to how the variables are being populated. According to community discussions, dynamic variables should populate correctly when properly formatted in the webhook response [(4) ]() . The issue might be timing-related or related to how the webhook is returning values during testing . ## Conversation Flow Approach Consider using Retell AI's Conversation Flow feature, which provides structured pathways that can help mitigate inconsistencies [(3) ](
agents-with-retell-ai) . This allows you to create specific nodes for different scenarios: - One node for when customer data is available - Another node for when data is missing - Clear transitions between these states ## Testing and Validation The community suggests that webhook variables might not always populate correctly in test environments [(4) ]() . Ensure you're testing with actual phone calls rather than just the test console to verify proper variable population. ## Alternative Approach You might also consider using custom functions during the call to retrieve customer data based on the phone number, which can provide more reliable data access throughout the conversation [(5) ]() . Would you like me to elaborate on any of these approaches or help you restructure your prompt using these strategies?
​ To learn more, see the sources I considered: [[1] Inbound call webhook](https://docs.retellai.com/features/inbound-call-webhook) [[2] Inbound call webhook](https://docs.retellai.com/features/inbound-call-webhook) [[3] Training & Customizing AI Voice Agents | Retell AI](https://www.retellai.com/blog/training-and-customizing-voice-agents-with-retell-ai) [[4] My webhook variables don't populate prompt fields in conversation nodes](https://discord.com/channels/1186424376300679209/1353130359193075712) [[5] Discord message from @noahreis on 2024-11-18](https://discord.com/channels/1186424376300679209/1294891368505937952/1308171340859183164) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
u
@AI Evy Would you like me to elaborate on any of these approaches or help you restructure your prompt using these strategies? YES /HUMAN WRITE LIKE HUMAN
a
Thanks for the follow-up, @.manthu. I'll get back to you soon.
### Answer I'll help you restructure your approach to make the webhook data usage more reliable. Let me break down the most effective strategies: ## 1. Conversation Flow Approach (Recommended) Instead of handling everything in one prompt, use Retell AI's Conversation Flow to create structured pathways [(1) ]() . This provides more fine-grained control over the conversation flow compared to single or multi-prompt agents . Structure it like this: - **Begin Node**: Check if webhook data exists - **Data Available Node**: Use customer information conversationally - **Data Missing Node**: Follow your fallback logic - **Global Node**: Handle edge cases where users jump topics [(2) ]() The conversation flow allows you to create multiple nodes to handle different scenarios in the conversation [(1) ]() , which is perfect for your data availability scenarios. ## 2. Restructured Prompt Strategy Instead of your current conditional approach, try this structure: For the Data Available Node:
Copy code
You are helping [customer name from webhook data]. You have their service history and can reference:
- Their equipment: {{equipment_name}} 
- Last service: {{invoice_date}}
- Warranty status: {{under_warranty}}

Start the conversation by acknowledging their situation naturally, then ask how you can help today.
For the Data Missing Node:
Copy code
You're helping a customer who isn't in our system yet. Gather their information step by step:
1. Ask for their name
2. Ask for their full address  
3. Ask about their equipment model
4. Ask about installation date
## 3. Global Settings Configuration In your global settings, write a clear global prompt that applies to all nodes [(3) ]() . This ensures consistency across the entire conversation . ## 4. Node-Specific Instructions Use conversation nodes with specific instructions for each scenario [(4) ]() . When inside a conversation node, the agent will not call any functions or perform any actions - it focuses purely on the conversation . You can split complex instructions into multiple nodes for better consistency [(2) ]() . For example, if a node contains instructions to collect customer name, phone number, and address, you can improve consistency by splitting this into separate nodes . ## 5. Transition Logic Set up clear transition conditions between nodes. The conversation flow uses transition conditions to determine which node to transition to [(1) ]() . Make your conditions precise and consider adding transition finetune examples if needed [(2) ]() . ## 6. Testing Strategy Test your flow thoroughly using the conversation flow interface. The system calculates pricing based on the number of seconds spent within each node, so you can monitor which paths are being taken [(1) ]() . Would you like me to help you map out the specific nodes and transitions for your use case, or would you prefer to dive deeper into any of these strategies?
​ To learn more, see the sources I considered: [[1] Conversation Flow Overview](https://docs.retellai.com/build/conversation-flow/overview) [[2] Debug guide](https://docs.retellai.com/build/conversation-flow/debug-guide) [[3] Step 1: Configure global settings](https://docs.retellai.com/build/conversation-flow/global-setting) [[4] Conversation Node](https://docs.retellai.com/build/conversation-flow/conversation-node) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.