Quickstart
Build one AI agent and reach it through two channels: a phone call and a text conversation. Choose the Server SDK or write SignalWire Markup Language (SWML) directly. Both paths produce one public agent configuration that you can connect to either channel.
Before you start, you need:
- A SignalWire account
- Python 3 and ngrok installed locally
- A SignalWire phone number for the Voice app
- Your Space name, project ID, and an API token with the
chatscope for the Chat app; manage tokens in the SignalWire Dashboard
Build and publish the agent
Choose one authoring path. Both paths create the same agent definition and give it a public configuration URL. You will connect that URL to a channel in the next step.
Server SDK
SWML
This quickstart uses Python throughout. The voice path is also available for TypeScript, but the AI Chat client used in the next step is currently available only for Python. See the Server SDK documentation for both SDKs.
Install the Server SDK
Write the agent
Create agent.py:
This is the complete agent application. agent.run() starts an HTTP server on port 3000 and
serves the SWML document that defines the agent.
Give the agent a public URL
In a second terminal, start ngrok:
Copy the HTTPS forwarding URL, such as https://abc123.ngrok-free.app. Keep ngrok running.
Start the agent with stable credentials
In the first terminal, set a URL-safe development password and the ngrok URL before starting the agent. Reuse these values for the rest of the quickstart.
The fixed credentials keep the agent URL valid if you restart the process. SWML_PROXY_URL_BASE
lets the SDK generate public callback URLs when you add tools later.
Verify the generated SWML
From another terminal, request the agent configuration through the tunnel:
A working agent returns a JSON document with "version": "1.0.0" and a sections.main array that
contains answer and ai methods. If the request returns 401, use the same credentials that you
exported before starting agent.py. If it cannot connect, confirm that both the agent and ngrok are
still running.
Write the agent configuration
Create swml.json:
The document is a complete SWML agent definition. answer accepts an incoming voice call, and ai
starts the agent with the prompt.
Serve the SWML document
Start a local development server in the directory containing swml.json:
This server is for the quickstart only. It does not add authentication, TLS, or production request handling.
Give the configuration a public URL
In a second terminal, start ngrok:
Copy the HTTPS forwarding URL, such as https://abc123.ngrok-free.app, and keep both processes
running. Set the complete configuration URL in any terminal where you run the Chat app:
Verify the SWML document
Request the document through the tunnel:
The command prints the same JSON document you created. If it cannot connect, confirm that the local
HTTP server and ngrok are running and that the URL ends in /swml.json.
Connect a channel
Voice and Chat use the same agent definition. Choose how you want to interact with the agent; you can return later and connect the other channel to the same configuration URL.
Voice app
Chat app
Route a phone number to the public configuration URL, then place a call.
Create an External URL resource
Open the SignalWire Dashboard, select Script, and then select External URL. Use the matching Primary Script URL:
Select Create.
Assign a phone number
Open Phone Numbers, select a number, and then select Edit Settings. Under Inbound Call Settings, choose Assign Resource, select the External URL resource, and save the change.
Place a call
Call the SignalWire number. The agent greets you and asks how it can help. If the call does not reach
the agent, request the configuration URL with curl again, then confirm that the phone number is
assigned to the same External URL resource.
The Chat app uses the same public configuration URL you created in the first step. This is the URL
that serves your agent’s SWML: the Server SDK’s root URL or the URL of your swml.json file.
AIChatClient passes it to SignalWire as config_url, and SignalWire fetches the agent definition
server-to-server. Keep API credentials on your server; do not put them in browser code.
Install the client and configure credentials
Install the package if you chose the SWML authoring path:
Export credentials from your SignalWire Space. SIGNALWIRE_SPACE is the Space name only, such as
example for example.signalwire.com. Export the configuration URL from the authoring path you
chose if it is not already present in this terminal.
Write the Chat app
Create chat.py:
The example uses a unique conversation ID, sends one complete turn, prints the response, and ends the conversation so post-processing can run.
Send a message
A working setup prints the agent’s greeting and its response to the question. An authentication
error usually means the project, token, and Space do not belong together. If conversation creation
fails while the earlier curl succeeds, confirm that SIGNALWIRE_AGENT_CONFIG_URL contains the
same public URL and any required Basic Auth credentials.
The AIChatClient reference documents every client method and return type. The AI Chat endpoint documents the JSON-RPC protocol underneath it.