@@ -6,7 +6,7 @@ This project is a Pipecat-based chatbot that integrates with Twilio to make outb
66
77When you want to make an outbound call:
88
9- 1 . ** Send POST request** : ` POST /start ` with a phone number to call
9+ 1 . ** Send POST request** : ` POST /dialout ` with a phone number to call
10102 . ** Server initiates call** : Uses Twilio's REST API to make the outbound call
11113 . ** Call answered** : When answered, Twilio fetches TwiML from your server's ` /twiml ` endpoint
12124 . ** Server returns TwiML** : Tells Twilio to start a WebSocket stream to your bot
@@ -16,7 +16,7 @@ When you want to make an outbound call:
1616## Architecture
1717
1818```
19- curl request → /start endpoint → Twilio REST API → Call initiated →
19+ curl request → /dialout endpoint → Twilio REST API → Call initiated →
2020TwiML fetched → WebSocket connection → Bot conversation
2121```
2222
@@ -30,7 +30,7 @@ TwiML fetched → WebSocket connection → Bot conversation
3030
3131### AI Services
3232
33- - OpenAI API key for the LLM inference
33+ - Google API key for the LLM inference
3434- Deepgram API key for speech-to-text
3535- Cartesia API key for text-to-speech
3636
@@ -97,7 +97,7 @@ The server will start on port 7860.
9797
9898 > Tip: Use the ` --subdomain ` flag for a reusable ngrok URL.
9999
100- Copy the ngrok URL (e.g., ` https://abc123.ngrok.io ` )
100+ Copy the ngrok URL (e.g., ` https://abc123.ngrok.io ` ) and update ` LOCAL_SERVER_URL ` in your ` .env ` file.
101101
1021023 . No additional Twilio configuration needed
103103
@@ -107,41 +107,22 @@ The server will start on port 7860.
107107
108108With the server running and exposed via ngrok, you can initiate outbound calls:
109109
110- ### Basic Call
111-
112- ``` bash
113- curl -X POST https://your-ngrok-url.ngrok.io/start \
114- -H " Content-Type: application/json" \
115- -d ' {
116- "phone_number": "+1234567890"
117- }'
118- ```
119-
120- ### Call with Body Data
121-
122- You can include arbitrary body data that will be available to your bot:
123-
124110``` bash
125- curl -X POST https://your-ngrok-url.ngrok.io/start \
111+ curl -X POST https://your-ngrok-url.ngrok.io/dialout \
126112 -H " Content-Type: application/json" \
127113 -d ' {
128- "phone_number": "+1234567890",
129- "body": {
130- "user": {
131- "id": "user123",
132- "name": "John Doe",
133- "account_type": "premium"
134- }
135- }
114+ "to_number": "+15551234567",
115+ "from_number": "+15559876543"
136116 }'
137117```
138118
139- The body data can be any JSON structure - nested objects, arrays, etc. Your bot will receive this data automatically.
140-
141119Replace:
142120
143121- ` your-ngrok-url.ngrok.io ` with your actual ngrok URL
144- - ` +1234567890 ` with the phone number you want to call
122+ - ` +15551234567 ` with the phone number to call (E.164 format)
123+ - ` +15559876543 ` with your Twilio phone number (E.164 format)
124+
125+ > Note: the ` from_number ` must be a phone number owned by your Twilio account
145126
146127## Production Deployment
147128
@@ -181,31 +162,6 @@ As you did before, initiate a call via `curl` command to trigger your bot to dia
181162
182163## Accessing Call Information in Your Bot
183164
184- Your bot automatically receives call information and body data through Twilio's Parameters:
185-
186- - ** Body Data** : Any data you include in the ` body ` field is passed as a JSON string in the ` body ` parameter
187-
188- The Pipecat development runner extracts this data using the ` parse_telephony_websocket ` function:
189-
190- ``` python
191- async def bot (runner_args : RunnerArguments):
192- transport_type, call_data = await parse_telephony_websocket(runner_args.websocket)
193-
194- if transport_type == " twilio" :
195- # Body data (JSON string parameter)
196- import json
197- body_param = call_data[" custom_parameters" ].get(" body" )
198- if body_param:
199- body_data = json.loads(body_param)
200-
201- # Access nested data
202- user_data = body_data.get(" user" , {})
203- user_id = user_data.get(" id" )
204- user_name = user_data.get(" name" )
205- user_account_type = user_data.get(" account_type" )
206-
207- # Use this data to personalize the conversation
208- print (f " User: { user_name} (ID: { user_id} , Type: { user_account_type} ) " )
209- ```
165+ Your bot automatically receives call information through Twilio Stream Parameters. In this example, the phone numbers (` to_number ` and ` from_number ` ) are passed as parameters and extracted by the ` parse_telephony_websocket ` function.
210166
211- This allows your bot to provide personalized responses based on the body data and context .
167+ You can extend the ` DialoutRequest ` model in ` server_utils.py ` to include additional custom data (customer info, campaign data, etc.) and pass it through as stream parameters for personalized conversations. See ` bot.py ` for implementation details .
0 commit comments