Skip to main content

sw-agent-init CLI

sw-agent-init CLI

Summary: Interactive project generator for creating new SignalWire agent projects with customizable features.

Overview

The sw-agent-init tool scaffolds new SignalWire agent projects with:

  • Pre-configured project structure
  • Agent class with example SWAIG tool
  • Environment configuration (.env files)
  • Optional debug webhooks for development
  • Test scaffolding with pytest
  • Virtual environment setup

Command Syntax

sw-agent-init [project_name] [options]

Quick Reference

CommandPurpose
sw-agent-initInteractive mode with prompts
sw-agent-init myagentQuick mode with defaults
sw-agent-init myagent --type fullFull-featured project
sw-agent-init myagent -p awsAWS Lambda project
sw-agent-init myagent -p gcpGoogle Cloud Function project
sw-agent-init myagent -p azureAzure Function project
sw-agent-init myagent --no-venvSkip virtual environment

Modes

Interactive Mode

Run without arguments for guided setup:

sw-agent-init

Interactive mode prompts for:

  1. Project name
  2. Project directory
  3. Agent type (basic or full)
  4. Feature selection
  5. SignalWire credentials
  6. Virtual environment creation

Quick Mode

Provide a project name for quick setup with defaults:

sw-agent-init myagent

Quick mode uses environment variables for credentials if available.

Options

OptionDescription
--type basicMinimal agent with example tool (default)
--type fullAll features enabled
--platform, -pTarget platform: local, aws, gcp, azure (default: local)
--region, -rCloud region for serverless deployment
--no-venvSkip virtual environment creation
--dir PATHParent directory for project

Agent Types

Basic Agent

Minimal setup for getting started:

  • Single agent class
  • Example SWAIG tool
  • Test scaffolding
  • Environment configuration
sw-agent-init myagent --type basic

Full Agent

All features enabled:

  • Debug webhooks (console output)
  • Post-prompt summary handling
  • Web UI with status page
  • Example SWAIG tool
  • Test scaffolding
  • Basic authentication
sw-agent-init myagent --type full

Features

Toggle features in interactive mode:

FeatureDescription
Debug webhooksReal-time call data printed to console
Post-prompt summaryCall summary handling after conversations
Web UIStatic file serving with status page
Example SWAIG toolSample get_info tool implementation
Test scaffoldingpytest-based test suite
Basic authenticationHTTP basic auth for SWML endpoints

Platforms

The --platform option generates platform-specific project structures:

Local (Default)

Standard Python server deployment:

sw-agent-init myagent
# or explicitly:
sw-agent-init myagent --platform local

AWS Lambda

Generates AWS Lambda function structure with handler:

sw-agent-init myagent -p aws
sw-agent-init myagent -p aws -r us-east-1

Generated structure includes:

  • handler.py - Lambda handler entry point
  • template.yaml - SAM template for deployment
  • Platform-specific requirements

Google Cloud Functions

Generates Google Cloud Function structure:

sw-agent-init myagent -p gcp
sw-agent-init myagent -p gcp -r us-central1

Generated structure includes:

  • main.py - Cloud Function entry point
  • Platform-specific requirements

Azure Functions

Generates Azure Function structure:

sw-agent-init myagent -p azure
sw-agent-init myagent -p azure -r eastus

Generated structure includes:

  • function_app.py - Azure Function entry point
  • host.json - Azure Functions host configuration
  • Platform-specific requirements

Generated Project Structure

Local Platform

myagent/
├── agents/
│ ├── __init__.py
│ └── main_agent.py # Main agent implementation
├── skills/
│ └── __init__.py # Reusable skills module
├── tests/
│ ├── __init__.py
│ └── test_agent.py # Test suite using swaig-test
├── web/ # Static files (full type only)
│ └── index.html
├── app.py # Entry point
├── .env # Environment configuration
├── .env.example # Example configuration
├── .gitignore
├── requirements.txt
└── README.md

Serverless Platforms

Serverless projects include platform-specific entry points instead of app.py:

PlatformEntry PointAdditional Files
AWS Lambdahandler.pytemplate.yaml
GCP Cloud Functionsmain.py-
Azure Functionsfunction_app.pyhost.json

Environment Variables

The tool auto-detects SignalWire credentials from environment:

VariableDescription
SIGNALWIRE_SPACE_NAMEYour SignalWire space
SIGNALWIRE_PROJECT_IDProject identifier
SIGNALWIRE_TOKENAPI token

Examples

Create Basic Agent

sw-agent-init support-bot
cd support-bot
source .venv/bin/activate
python app.py
sw-agent-init customer-service --type full
cd customer-service
source .venv/bin/activate
python app.py

Create Without Virtual Environment

sw-agent-init myagent --no-venv
cd myagent
pip install -r requirements.txt
python app.py

Create in Specific Directory

sw-agent-init myagent --dir ~/projects
cd ~/projects/myagent

Create AWS Lambda Project

sw-agent-init my-lambda-agent -p aws -r us-west-2
cd my-lambda-agent
# Deploy with SAM CLI
sam build && sam deploy --guided

Create Google Cloud Function Project

sw-agent-init my-gcf-agent -p gcp -r us-central1
cd my-gcf-agent
# Deploy with gcloud
gcloud functions deploy my-gcf-agent --runtime python311 --trigger-http

Create Azure Function Project

sw-agent-init my-azure-agent -p azure -r eastus
cd my-azure-agent
# Deploy with Azure CLI
func azure functionapp publish <app-name>

Running the Generated Agent

After creation:

cd myagent
source .venv/bin/activate # If venv was created
python app.py

Output:

SignalWire Agent Server
SWML endpoint: http://0.0.0.0:5000/swml
SWAIG endpoint: http://0.0.0.0:5000/swml/swaig/

Testing the Generated Agent

Run the test suite:

cd myagent
source .venv/bin/activate
pytest tests/ -v

Or use swaig-test directly:

swaig-test agents/main_agent.py --dump-swml
swaig-test agents/main_agent.py --list-tools
swaig-test agents/main_agent.py --exec get_info --topic "SignalWire"

Customizing the Agent

Edit agents/main_agent.py to customize:

  • Prompts and personality
  • Voice and language settings
  • SWAIG tools and handlers
  • Debug and webhook configuration

See the Building Agents chapter for detailed guidance.