https://retellai.com/?utm_source=discord&utm_medium=seo logo
trunking and RAG
# ❓・ai-evy-support
n
@AI Evy trunking and RAG
a
Thanks for tagging me @Nameless. I'll look through relevant sources and get back to you shortly.
### Answer Your message is a bit open-ended, so here's an overview of both topics as they're documented for Retell AI. Tell me which part you want to go deeper on. ## SIP trunking Retell AI supports Elastic SIP Trunking, which is the recommended way to connect your own telephony provider. Providers like Twilio, Telnyx, and Vonage are supported. With this setup, your VoIP-based AI agents connect to the PSTN for inbound and outbound calls.[(1)]() Setup steps: - **Configure URIs**: Set the termination (outbound) and origination (inbound) SIP URIs so calls route through Retell AI's SIP server.[(1)]() - **Authentication**: Retell AI's SIP server does not have a static IP, so credential-based authentication is often preferred over IP whitelisting.[(1)]() - **Import your numbers**: Import numbers in E.164 format and provide the termination URI that identifies your elastic SIP trunk. For Twilio, this URI typically ends with ".pstn.twilio.com". You can also bind an agent ID, add a nickname, and supply a SIP trunk username and password.[(1)]() Phone number objects expose this configuration through
sip_outbound_trunk_config
, which includes
termination_uri
,
auth_username
, and
transport
.[(2)]() You can read it via the phone number endpoints, for example:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: process.env['RETELL_API_KEY'], // This is the default and can be omitted
});
const phoneNumberResponse = await client.phoneNumber.retrieve('+14157774444');
console.log(phoneNumberResponse.last_modification_timestamp);
[(2)]() ## RAG (Knowledge Base) Retell AI offers knowledge base integration for RAG. Conversation flows accept
knowledge_base_ids
and a
kb_config
for RAG retrieval configuration.[(3)]() Behavior to be aware of: - **Semantic retrieval**: Only a limited number of relevant chunks are surfaced per query, so the knowledge base works best for contextual Q&A rather than exhaustive lookups. For complete, finite lists (like a restaurant menu), putting all items directly in the prompt is the recommended approach.[(4)]() - **Chunking**: Loading information in smaller, categorized chunks can improve accuracy, and pricing or other exact data is better fetched from your backend than stored in the knowledge base.[(4)]() - **Past conversations**: RAG isn't the right fit for remembering a user's previous calls. Instead, pass a summarized version of the conversation history into the prompt using dynamic variables.[(5)]()
​ To learn more, see the sources I considered: [[1] AI in SIP Calling & Telephony Solutions | Retell AI](https://www.retellai.com/blog/integrating-ai-with-sip-trunking-and-modern-telephony) [[2] Get Phone Number](https://docs.retellai.com/api-references/get-phone-number) [[3] Create Conversation Flow](https://docs.retellai.com/api-references/create-conversation-flow) [[4] The knowledge base is useless.](https://discord.com/channels/1186424376300679209/1470697086981902513) [[5] RAG from past conversations with same user?](https://discord.com/channels/1186424376300679209/1292040673226391592) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
n
so what is the knowledge base instruction anything to do with RAG @AI Evy
a
Thanks for the follow-up, @Nameless. I'll get back to you soon.
### Answer The Knowledge Base Instruction is an optional setting that guides how Retell builds the search query used for knowledge base retrieval, so yes, it's part of the RAG flow. Before each retrieval, Retell condenses the recent conversation into a short, standalone search query and uses that query to find the most relevant chunks. The instruction gives that step extra guidance, such as which topics or terms to prioritize.[(1)]() Key points: - **It shapes the search query only**: It does not filter or rewrite the retrieved chunks. To control how much content comes back, use "Chunks to retrieve" (1-10, default 3) and "Similarity Threshold" (default 0.6).[(1)]() - **Limits**: Keep it short and specific, up to 500 characters.[(1)]() - **When to use it**: Most cases can leave it empty, since default query building works well. Add an instruction when retrieval keeps focusing on the wrong topic or misses context you expect.[(1)]() - **Where to set it**: Under Knowledge base & memory, expand Advanced Settings and select Configure Knowledge Base Instruction.[(1)]() - **Per-node override**: For Conversation Flow agents in Rigid Mode, you can set it per Conversation Node or Subagent Node. Under Node settings → Node-level overrides, enable Knowledge Base Retrieval, then select Configure Knowledge Base Instruction. A node-level instruction overrides the flow-level one while that node is active.[(1)]() To debug retrieval, open the call in Call History and select the Knowledge Base Retrieval link above an agent message in the transcript. It shows the exact chunks passed to
the LLM for that turn.[(1)]()
​ To learn more, see the sources I considered: [[1] Knowledge base setup and retrieval tuning](https://docs.retellai.com/build/knowledge-base) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.