最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Twilio To Retell Call Transfer and back to Twilio - Stack Overflow

programmeradmin2浏览0评论

I am trying to develop a system where callers call my Twilio number and I want them to talk to my AI Voice agent in Retell. My AI voice agent will gather their first name and last name and then I want Retell to transfer the call back to Twilio for further processing.

So far I have done the following:

  1. Twilio incoming call transfer to Retell using Retell Register call api endpoint. This step is working fine and allowing to dail sip and the call is getting transferred to Retell Voice AI agent.

  2. Retell AI Voice agent is talking and capturing their first and last name and posting data through webhook to my server. This step is also working fine.

  3. Now, I want the call routed back to Twilio. So I am using transfer call function in Retell to transfer the call back to Twilio. I am stuck at this point. I am transferring the call back to Twilio by transferring to a different number in Twilio. Now call in point 1 is different to this transfer which I don't want.

Twilio To Retell Transfer:

$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL => ";,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "{\n  \"agent_id\": \"agent_0aa908475hydtgf4ebc5406973\",\n  \"from_number\": \"+19876543210\",\n  \"to_number\": \"+19988776655\",\n  \"direction\": \"inbound\"\n}",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer Retell_API_KEY_Here",
        "Content-Type: application/json"
   ],
]);
$response_retell = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
    echo "cURL Error #:" . $err;
} else {
    $response_retell = json_decode($response_retell);
    $dial = $response->dial();
    $dial->sip("sip address here");
}
return $response;

How can I transfer the call back to Twilio from Retell keeping everything under one call? Can someone guide me to the correct way please?

发布评论

评论列表(0)

  1. 暂无评论