#how to get the phone number of the caller in the post-call webhook when my agent is connected to a

1 messages · Page 1 of 1 (latest)

proper orchidBOT
#
AI-generated Answer for aironeken

To get the phone number of the caller in a post-call webhook when your agent is connected to a Twilio number, you can use Twilio's statusCallback parameter. This allows you to specify a URL that Twilio will notify when the call status changes, such as when the call is completed.

Here’s an example setup in Node.js:

const VoiceResponse = require('twilio').twiml.VoiceResponse;

app.post('/call/incoming', (_, res) => {
    const twiml = new VoiceResponse();
    twiml.connect().stream({ url: `wss://${process.env.SERVER_DOMAIN}/call/connection` });

    // Add statusCallback to handle call completion
    twiml.dial({
        statusCallback: 'https://your-server.com/call-status',
        statusCallbackEvent: ['completed'],
    });

    res.writeHead(200, { 'Content-Type': 'text/xml' });
    res.end(twiml.toString());
});

In this example:

  • Replace 'https://your-server.com/call-status' with the URL of your endpoint where you want to receive the webhook.
  • Twilio will send a POST request to this URL when the call is completed, including details such as the caller_id (the phone number of the caller).

Make sure your webhook endpoint is set up to handle the incoming data and extract the caller_id parameter from the request payload. This will allow you to use the caller's phone number for any post-call processing.

gleaming sedge
#

No I need to receive it from elevenlabs because I need to match it with the elevenlabs conversation details

proper orchidBOT
#
AI-generated Answer for aironeken

When using ElevenLabs Conversational AI with Twilio, the phone number of the caller (caller_id) is included in the webhook call made by ElevenLabs to your specified endpoint. This happens when a Twilio call is received. Along with caller_id, other details like agent_id, called_number, and call_sid are also passed as arguments.

You can use this information to match the caller's phone number with the ElevenLabs conversation details. For more details on how this works, you can refer to the documentation on dynamic calls.

gleaming sedge
# proper orchid

I need to request them or the called_id will be passed in the post-call webhook?