How to use agents with inbound and outbound phone calls.
TelephonyServer
locally)brew install ffmpeg
brew install redis
.env.template
file and fill in the values of your API keys. You’ll need to get API keys for:ngrok
: in our code we set it up to be running on port 3000, run:.env
without https://
, e.g.
TelephonyServer
is–as implied by the name–a server that is responsible for
receiving and making phone calls.
The server is built using FastAPI and utilizes Twilio for telephony services.
Clone the Vocode repo or copy the Telephony app directory.
telephony_app
directory, run:docker-compose
. From the telephony_app
directory, run:telephony_app
directory.
uvicorn
(should be already installed in step 1).https://<YOUR BASE URL>/inbound_call
- if you’re using ngrok
, it looks like https://asdf1234.ngrok.app/inbound_call
outbound_call.py
Replace the to_phone
with the number you want to call and the from_phone
with the number you want to call from. In order to make a call from the from_phone
, you must have access to it via Twilio (either a number purchased via Twilio or verify the caller ID).
Run the script with poetry run python outbound_call.py
.
OutboundCall
(in outbound_call.py
) and InboundCallConfig
(in telephony_app.py
) classes can accept a TranscriberConfig
, AgentConfig
or SynthesizerConfig
- the default transcriber is Deepgram and the default synthesizer is Azure.
This example sets up an agent that spells every word that is sent to it - any text-in, text-out function can be turned into a voice conversation by subclassing BaseAgent
and creating an AgentFactory
.
AgentFactory
instance is passed into the TelephonyServer
in telephony_app.py
.
We provide a small set of agents with already created AgentConfig
s, including, importantly, one that sets up ChatGPT with a configured prompt: see our Python Quickstart
for more info.
to
and from
numbers in the ConfigManager
- so
if you’d like to access them in your agent, you can instantiate the manager to hook into the same Redis instance: