diff --git a/plivo-chatbot/outbound/README.md b/plivo-chatbot/outbound/README.md index 9373e6c2..bc7f953f 100644 --- a/plivo-chatbot/outbound/README.md +++ b/plivo-chatbot/outbound/README.md @@ -180,6 +180,15 @@ When `ENV=production`, the server automatically routes WebSocket connections to As you did before, initiate a call via `curl` command to trigger your bot to dial a number. -## Accessing Call Information in Your Bot +## Accessing Custom Data in Your Bot -Your bot automatically receives caller information through query parameters in the WebSocket URL. The server extracts the `From` and `To` phone numbers and passes them as `body` data to your bot via the WebsocketRunnerArguments (coming soon!). +Your bot receives custom data through `runner_args.body`: + +```python +async def bot(runner_args: RunnerArguments): + body_data = runner_args.body or {} + first_name = body_data.get("user", {}).get("firstName", "there") + # Use first_name to personalize greetings, prompts, etc. +``` + +This approach works consistently in both local development and Pipecat Cloud production deployments. diff --git a/plivo-chatbot/outbound/server.py b/plivo-chatbot/outbound/server.py index 5918c4fb..8b4c3716 100644 --- a/plivo-chatbot/outbound/server.py +++ b/plivo-chatbot/outbound/server.py @@ -273,12 +273,8 @@ async def websocket_endpoint( from bot import bot from pipecat.runner.types import WebSocketRunnerArguments - # Create runner arguments and run the bot - runner_args = WebSocketRunnerArguments(websocket=websocket) - runner_args.handle_sigint = False - - # TODO: When WebSocketRunnerArguments supports body, add it here: - # runner_args = WebSocketRunnerArguments(websocket=websocket, body=body_data) + # Create runner arguments with body data + runner_args = WebSocketRunnerArguments(websocket=websocket, body=body_data) await bot(runner_args)