how to route to specific phone_number_id , assista...
# support
j
@staticmethod def transfer_call_to_vapi(request_body): """Send a request to Vapi to handle the inbound call.""" # todo check vapi assistant limit vapi_url = AssistantConstants.VAPI_INBOUND_CALL_BACK_URL headers = {} payload = request_body response = InternalRequestHandler.post(url=vapi_url, json=payload, headers=headers) return response where vapi_url is "https://api.vapi.ai/twilio/inbound_call" and payload is request body from twilio-incoming webhook
def twilio_inbound_call(request_body): """Receive Twilio incoming call webhook and forward it to Vapi.""" Caller = request_body.get("Caller", "") CallSid = request_body.get("CallSid", "") To = request_body.get("To", "") From = request_body.get("From", "") ai_assistant_number = AiAssistantNumberMapping.objects.filter(phone_number=To, assistant__assistant_type=AssistantConstants.INBOUND_CALL_ASSISTANT).last() ai_assistant_provider= AiProvider.objects.filter().order_by('-id').first() # Prepare payload for Vapi assistant_overrides = { 'current_time': datetime.now().strftime('%Y-%m-%d %H:%M:%S') } payload = { "phoneCallProviderBypassEnabled": True, "type": "inboundPhoneCall", "assistantId": ai_assistant_number.ai_assistant_id, "phoneNumber": { "provider": "twilio", "number": ai_assistant_number.phone_number }, "customer": { "number": From }, "phoneNumberId":ai_assistant_number.phone_number_id, } headers = { "Content-Type": "application/json", "Accept": "application/json", "Authorization": f"Bearer {ai_assistant_provider.auth_token}" } # Send request to Vapi response = InternalRequestHandler.post("https://api.vapi.ai/call", json=payload, headers=headers) return response is this correct approach
v
Hi Jennifer, could you please add a description of what you’re looking for? That way, I can better understand your needs and suggest some options that might be a good fit.
j
i want to redirect my twilio incoming calls to specific assistant of vapi
"https://api.vapi.ai/twilio/inbound_call" iam using this
payload is twilio payload
how to send assistant to the above endpoint
v
Hey @jennifer You can assign an assistant ID to the phone number if you prefer to use it instead of binding the call yourself. This way, you don’t have to manage end the call and transfer functionality by yourself. Check this code it does the same, which your looking out for.
l
Could one transfer outbound call to the assistant? So create call in Twilio, send to assistant? The reason I'm asking is because I need to tell Twilio to record it and need the recordings there. It seems I cannot pass such twilio specific parameters through Vapi 😦
v
Yes you can absolutely go about it that way.