How It Works
- Twilio Call: A call is made to one of your Twilio phone numbers.
- Webhook Request: Twilio sends a
POST
request to this/twiml
endpoint. - Assistant Lookup: The system identifies the appropriate assistant based on the phone number called (for inbound) or metadata (for outbound).
- Database Record: A new call record is created in the database.
- TwiML Response: The server responds with TwiML containing a
<Connect>
verb, instructing Twilio to connect to the/streams
WebSocket endpoint.
Request from Twilio
This endpoint consumesapplication/x-www-form-urlencoded
data sent by Twilio. The following are the key parameters your system uses:
CallSid
(string): A unique identifier for the call, provided by Twilio.To
(string): The Twilio phone number that was called.From
(string): The phone number of the person initiating the call.
assistant_id
and a welcome_message
.
Response to Twilio
The response is not JSON, but rather an XML document in TwiML format. It instructs Twilio to connect to your WebSocket server to begin streaming audio.Response
Response
200 - application/json
Successful Response
The response is of type any
.