Implements a chatbot that uses Twilio and Neuphonic Agents.
Get all the API Keys and resources set up:
- Head over to Twilio Docs: Make an Outbound Call
to buy a phone number, get your
TWILIO_ACCOUNT_SIDandTWILIO_AUTH_TOKEN. - Head over to Neuphonic to get your
NEUPHONIC_API_KEY. - Set up your environment variables:
Note -
cp .env.example .env
TO_NUMBERis your phone number.FROM_NUMBERis the number that you bought from Twilio. - Head over to ngrok, create and account and install the CLI.
Set up your environment: Use whichever package manager you want.
pip install -r requirements.txtRun the server:
- Run
ngrok.This will display a URL on your terminal, C+P this into thengrok http http://localhost:8000.envfile asSERVER_BASE_URLThis should look something like27ce-34-147-167-1.ngrok-free.app, do not C+P thehttps://at the front. - Run the FastAPI server that Twilio will connect to:
make run
Your local FastAPI server is now accessible via the ngrok HTTPS URL, so that Twilio can hit your server which is running on your laptop.
Initiate a call to your phone
python ./scripts/outbound_call.pyThis will trigger a call to your phone, with the Neuphonic agents endpoint. All logic for this call lives in ./twilio_chatbot/routers/agent.py.