Skip to main content
In this guide, we will show how to integrate Infer API with phone call using Twilio. If you would like to integrate to other platforms, reach out to us.
1

Buy a phone number from Twilio (skip it, if you have one from Twilio)

Go here and create an account and buy a phone number from Twilio. If you’re creating a new account Twilio will give you $15 to get started and hence it won’t put a hole in your pocket.
2

Get Twilio Auth Token and Account SID

Visit the Twilio Console API Keys page to obtain your Twilio Auth Token and Account SID. These details are essential for setting up the Twilio voice webhook, which enables Twilio to determine the appropriate destination for handling your incoming and outgoing calls linked to your Twilio number.
3

Infer API key

You can either email us at vaibhav@infer.so to get the API key or use the API key that we provided you to get started.
4

Create Your First Voice Agent 🤖

Follow the following steps to build your first voice agent. You can also build your first voice agent by directly going here and playing with parameters to make more customized voice agent and understanding different parameters:
const options = {
  method: 'POST',
  headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
  body: '{"initial_text":"Welcome to our service. I am an AI voice agent, how can I assist you today?","prompt":"You are a virtual assistant speaking with Infer who can answer queries about any topic.","responsiveness":0.2,"voice_id":"Alice (female)","voice_agent_expressiveness":0.28,"end_call_on_goodbye":true,"end_call_on_silence":30,"hipaa_compliance":true,"twilio_config":{"auth_token":"<string>","account_sid":"<string>","number":"<string>","update_webhook":true,"record":true},"custom_llm":{"url":"<string>","api_key":"<string>","model":"<string>"},"actions":{"transfer_calls":{"number_dict":{},"user_message":"<string>"},"google_sheet":true,"hangup_call":true}}'
};

fetch('https://voiceagent.infers.co/api/agent/create_new_agent', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
Make sure to copy the voice_agent_id from the response. If you face any issues, send us an email here.You can create multiple voice agents for different purposes like one for Outbound Lead Generation another one for handling inbound calls only etc.
5

Initiate your first outbound call 📞

Using the voice_agent_id from the last step and after understanding the parameters here run the following code which will initiate the call to the specific number:
const options = {
  method: 'POST',
  headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
  body: '{"voice_agent_id":"<string>","initial_text":"Hello, this is your virtual assistant calling. How can I assist you today?","prompt_values":{"name":"John Doe"},"to_phone":"+1234567890"}'
};

fetch('https://voiceagent.infers.co/api/calls/start_outbound_call', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
6

Initiate your first inbound call 📞

To initiate an inbound call, you don’t have to change anything. Follow the steps below:
  1. Call the Twilio number you configured in Step 1.
  2. You should hear your AI Voice Agent respond, using the initial text and following the prompt you set in Step 4.
  3. Interact with the AI voice agent to ensure it’s working as expected.
Monitor your inbound calls to ensure your AI Voice Agent is performing correctly. If you need to make adjustments, you can modify your voice agent settings using the API as described in the earlier steps. If you encounter any issues or need assistance, don’t hesitate to reach out to us.