Retellai: Direct Call Routing
Pay close attention to the following
This tutorial is based on using JavaScript based Container Applications. Make sure that you choose the correct runtime
for your container application.
In this tutorial, we will learn how to create a direct call routing container application for Retellai. Direct call routing allows you to route calls directly to specific endpoints without using a call routing rule.
The Source Code
basic assumptions
- The provided script will handle any inbound call.
- The provided script will simply route the inbound call to Reteall, based on the destination provided.
function dialToRetell(ev) {
let result = `<Dial callerId="${ev.parameters.From}">\n`;
result += ` <Service provider="retell">${ev.parameters.To}</Service>\n`;
result += `</Dial>`;
return result;
}
function response(content) {
let result = `<?xml version="1.0"?>`;
result += `<Response>${content}</Response>`;
return result;
}
exports.handler = async (ev) => {
const retellRoutingCxml = dialToRetell(ev);
return response(retellRoutingCxml);
};
In-Depth Explanation
The above scripts defines a function dialToRetell that takes the inbound event as input. This function constructs a
CXML response that includes a <Dial> element with the callerId set to the provided From number and a <Service>
element with the provider set to retell. The destination number is set to the provided To number.