Outbound call Assistant with Twilio number
# support
l
Hi, I have an assistant configured to make calls using a Twilio number. The calls are working and assistant works well. However, I need Twilio to make the recordings and also send callbacks to our backend service to then retrieve such recordings. When I try to pass on these parameters to the VAPI API it doesn't recognise the parameters. For data compliance reasons I need the recordings on Twilio, so I would like to figure out how to do this. If this was written to start from Twilio's end, using their API, the options would look like this
Copy code
call = twilio_client.calls.create(
            url=webhook_url,
            to=phone_number,
            from_=TWILIO_PHONE_NUMBER,
            status_callback=TWILIO_STATUS_CALLBACK_URL,
            status_callback_event=["initiated", "ringing", "answered", "completed"],
            record=True,
            recording_track="both",
            recording_channels="dual",
            recording_status_callback=TWILIO_RECORDING_STATUS_CALLBACK_URL,
        )
but when I try sending these parameters to VAPI the parameters are not recognised. Is there a way to pass this along? Alternatively to configure in UI, maybe this could be done at Assistant level?
Copy code
payload = {
            "assistantId": VAPI_ASSISTANT_ID,
            "customer": {
                "name": customer_name,
                "number": customer_number
            },
            "statusCallbackUrl": TWILIO_STATUS_CALLBACK_URL,
            "phoneNumberId": VAPI_PHONE_NUMBER_ID,
            "recording": {
                "enabled": True,
                "dualChannel": True,  # Ensure dual-channel recording
                "statusCallbackUrl": TWILIO_RECORDING_STATUS_CALLBACK_URL
            }
        }

        async with httpx.AsyncClient() as client:
            try:
                response = await client.post(VAPI_API_URL, json=payload, headers=headers)
Thank you!
v
Hi there! 👋 Based on the documentation I found, I can help with configuring call recordings and callbacks with VAPI and Twilio, though there are some differences from your approach. For enabling recordings in VAPI, you need to configure the
artifactPlan
in your assistant:
Copy code
json
{
  "artifactPlan": {
    "recordingEnabled": true,
    "transcriptPlan": {
      "enabled": true
    }
  }
}
When integrating Twilio with VAPI, you'll need to: 1. Set up a webhook on Twilio to handle incoming calls 2. Create a VAPI call with
phoneCallProviderBypassEnabled: true
3. Establish WebSocket connections for audio streaming For handling Twilio callbacks, you can configure your backend endpoint like this:
Copy code
javascript
app.post('/twilio/status', async (req, res) => {
  const { CallSid, RecordingStatus } = req.body;
  // Handle recording status
  console.log(`Recording for Call SID ${CallSid} has status: ${RecordingStatus}`);
  res.sendStatus(200);
});
I wasn't able to find specific information about passing Twilio recording parameters directly through VAPI API as you're attempting to do. VAPI seems to handle recordings through its own configuration rather than passing parameters to Twilio. For your compliance requirements, you might need to: 1. Use VAPI's
phoneCallProviderBypassEnabled
mode 2. Set up the WebSocket bridge as shown in the documentation 3. Configure your Twilio webhook to handle the recording parameters separately Would you like me to provide more details on any specific part of this integration? Source: - [VAPI Docs](https://docs.vapi.ai/phone-calling)
l
I'm not sure the flow here is very clear. Where are the incoming calls coming from?
v
The VAPI API doesn't directly expose all Twilio recording parameters that you're trying to use (like recording_track, recording_status_callback, etc.). @lievcin but let me check with the team and get back to you on this.