Dev Environment
Development Environment Setup
Configure a professional development environment for building SignalWire agents with proper project structure, environment variables, and debugging tools.
Recommended Project Structure
Create the Project
Environment Variables
Create a .env file for configuration:
Important: The SWML_BASIC_AUTH_USER and SWML_BASIC_AUTH_PASSWORD environment variables let you set stable credentials for your agent. Without these:
- Username defaults to
signalwire - Password is randomly generated on each startup
- The generated password is printed to the console
For development, you can leave these unset and use the printed credentials. For production, always set explicit values.
Create .env.example as a template (safe to commit):
Loading Environment Variables
Install python-dotenv:
Load in your agent:
The .gitignore File
Requirements File
Create requirements.txt:
Or generate from current environment:
IDE Configuration
VS Code
Create .vscode/settings.json:
Create .vscode/launch.json for debugging:
PyCharm
- Open Settings → Project → Python Interpreter
- Select your virtual environment
- Go to Run → Edit Configurations
- Create a Python configuration:
- Script path:
main.py - Working directory: Project root
- Environment variables: Load from
.env
- Script path:
Using swaig-test for Development
The swaig-test CLI is essential for development:
Development Workflow
1. Edit Code
Modify your agent in agents/.
2. Quick Test
swaig-test agents/my_agent.py --dump-swml- Verify SWML looks correct
3. Function Test
swaig-test agents/my_agent.py --exec my_function --arg value- Verify function returns expected result
4. Run Server
python main.pycurl http://localhost:3000/
5. Integration Test
- Start ngrok (see next section)
- Configure SignalWire webhook
- Make test call
Sample Agent Module
Testing Your Agent
Run tests:
Next Steps
Your development environment is ready. Now let’s expose your agent to the internet so SignalWire can reach it.