Local Development
Deployment
Deploy your agents as local servers, production services, or serverless functions. This chapter covers all deployment options from development to production.
What You’ll Learn
This chapter covers deployment options:
- Local Development - Running agents during development
- Production - Deploying to production servers
- Serverless - AWS Lambda, Google Cloud Functions, Azure Functions
- Docker & Kubernetes - Container-based deployment
- CGI Mode - Traditional web server deployment
Deployment Options Overview
Environment Detection
The SDK automatically detects your deployment environment:
Chapter Contents
Quick Start
The run() method automatically:
- Detects serverless environments (Lambda, Cloud Functions, Azure)
- Starts a development server on localhost for local development
- Handles CGI mode when deployed to traditional web servers
Starting the Development Server
The simplest way to run your agent locally:
Server Configuration
Custom Host and Port
Using serve() Directly
For more control, use serve() instead of run():
Development Endpoints
Testing Your Agent
View SWML Output
Using swaig-test CLI
Exposing Local Server
SignalWire needs to reach your agent via a public URL. Use ngrok or similar:
Connection Flow: SignalWire Cloud → ngrok tunnel → localhost:3000
Steps:
- Start your agent:
python my_agent.py - Start ngrok:
ngrok http 3000 - Use ngrok URL in SignalWire:
https://abc123.ngrok.io
Using ngrok
ngrok provides a public URL like https://abc123.ngrok.io that forwards to your local server.
Using localtunnel
Environment Variables for Development
Proxy URL Configuration
When behind ngrok or another proxy, the SDK needs to know the public URL:
Development Workflow
1. Code
Write/modify your agent code.
2. Test Locally
swaig-test my_agent.py --dump-swmlswaig-test my_agent.py --exec function_name --param value
3. Run Server
python my_agent.py
4. Expose Publicly
ngrok http 3000
5. Test with SignalWire
Point phone number to ngrok URL and make test call.
Debug Mode
Enable debug logging:
Or via environment variable:
Hot Reloading
For automatic reloading during development, use uvicorn directly:
Or create a development script:
Then run:
Serving Static Files
Use AgentServer.serve_static_files() to serve static files alongside your agents. This is useful for web dashboards, documentation, or any static content:
Directory Structure:
Key Points:
- Use
server.serve_static_files(directory)to serve static files - Agent routes always take priority over static files
- Requests to
/serveindex.htmlfrom the static directory - Both
/supportand/support/work correctly with agents
Route Priority: