https://retellai.com/?utm_source=discord&utm_medium=seo logo
What should the ideal prompt look like, what's the...
# ❓・ai-evy-support
a
@AI Evy What should the ideal prompt look like, what's the optimal number of tokens, how should it call external functions, how to integrate with n8n and Retool's native SMS tools, and what can be done to minimize hallucinations?
a
Thanks for tagging me @Axel. I'll look through relevant sources and get back to you shortly.
### Answer --- ## Optimal Token Count The LLM prompt token limit is 32,768 tokens. [(1) ]() For billing purposes, prompts up to 3,500 tokens follow the flat rate. Prompts exceeding 3,500 tokens will scale proportionally in cost. [(2) ]() What's included in token calculation: - Global prompt - Functions (tool descriptions) - State/node prompt - Transcript between agent and user - Tool call history and results ## Ideal Prompt Structure The general prompt should focus on style guardrails and call flow. [(3) ]() Use LLM States to split complex conversations into distinct stages—each with its own prompt and allowed tools. This helps reduce prompt length and tool choices, allowing the LLM to better focus and follow rules, minimizing hallucination. [(4) ]() [(5) ]() [(6) ]() Example state structure:
Copy code
json
{
  "name": "information_collection",
  "state_prompt": "You will follow the steps below to collect information...",
  "edges": [
    {
      "destination_state_name": "appointment_booking",
      "description": "Transition to book an appointment."
    }
  ]
}
[(6) ]() ## Calling External Functions (Custom Functions) Custom functions let you integrate external APIs. When called, Retell sends a request to your specified URL. [(7) ]() Key steps: 1. Add a custom function with a unique name (e.g.,
get_user_details
) 2. Select HTTP method (GET, POST, PUT, PATCH, DELETE) 3. Add your endpoint URL 4. Define parameters using JSON schema 5. Include in your prompt when to invoke the function, e.g.:
Copy code
When user provided the city name, please get the weather for that city by calling the `get_weather` function.
## n8n Integration Retell has native Make integration available at [(1) ]() For n8n specifically, there's an integration mentioned in the changelog. ## SMS Tools Retell has a built-in Send SMS tool that sends one-way SMS from the agent number to the user's number during a phone call. [(8) ]() This only works for phone numbers with SMS enabled (currently only Retell Twilio numbers) . You can write a prompt to let the agent infer the SMS content, or use static SMS content with dynamic variable support. ## Minimizing Hallucinations 1. Use LLM States — shorter prompts and fewer tools help the LLM focus and follow rules [(4) ]() [(5) ]() [(6) ]() 2. Keep prompts concise — use knowledge bases for external RAG instead of stuffing everything into the prompt [(3) ]() 3. Lower model temperature — a lower value is recommended for tool calling (value 0 is default) [(4) ]() [(5) ]() [(6) ]() 4. Enable strict mode for tool calls — set
tool_call_strict_mode: true
---
​ To learn more, see the sources I considered: [[1] Platform Changelogs | Retell AI](https://www.retellai.com/changelog) [[2] Exceptions to Our Per-Minute Pricing](https://docs.retellai.com/accounts/billing-exceptions) [[3] Prompt exceeds the limit of 32768 tokens, please contact support if you need longer context.](https://discord.com/channels/1186424376300679209/1432544872421789789) [[4] Update Retell LLM](https://docs.retellai.com/api-references/update-retell-llm) [[5] Get Retell LLM](https://docs.retellai.com/api-references/get-retell-llm) [[6] Create Retell LLM](https://docs.retellai.com/api-references/create-retell-llm) [[7] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) [[8] Send SMS](https://docs.retellai.com/build/single-multi-prompt/send-sms) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.