Building phone bot with Voximplant and api.ai

Alexey Aylarov
4 min readJul 3, 2017

--

Automation lets businesses significantly reduce costs and make number of processes more efficient, it also provides scalability when business grows fast. It’s no wonder that revolution that happens in ML/AI space at the moment is very important for both developers and businesses. A lot of new tools and services appear every day. At Voximplant we are focused on the communications layer, but we understand that offering easy to use tools for developers for building automated call scenarios is very important, that’s why we have realtime Text-to-Speech and ASR/Speech-to-Text available for our developers out of the box. In this post I would like to explain how to build telephony bot using available Voximplant APIs and api.ai in minutes. You can change api.ai to any other service that can handle natural language processing it won’t change the idea too much.

Setting up api.ai

The first step in api.ai is a creation of a new agent, let’s call it VoximplantCrunchbase

Then define a new intent, let’s call it FoundersIntent

We need to specify a number of expressions (examples) for api.ai to let it identify the intention and assign any parameter to a company name, we will be using this parameter in our VoxEngine scenario to get info about a company from Wikipedia. There is a very convenient ‘Try it now’ panel on the right where you can test your intents.

Setting up Voximplant

Create your free developer account at https://voximplant.com/sign-up/ , log in and create your first application in Applications, let’s name it voxbot

Now we can get virtual phone number for testing purposes at https://manage.voximplant.com/#numbers , use switch to show test numbers and choose any number from them, I chose one from Gotham City ;)

At https://manage.voximplant.com/#mynumbers assign the virtual number to the application

Now we can start writing our JavaScript call control scenario that will be executed by VoxEngine when call arrives to the platform. Open https://manage.voximplant.com/#scenarios and click Create Scenario button, let’s call it voxbot

Don’t forget to specify your api.ai accessToken. You can see that we used WikiInfobox function in the code, this function parses Wikipedia’s infobox to extract JSON data, we will create additional scenario for that, let’s call it xwiki , you can find its code at

https://gist.github.com/aylarov/dc8017f9935bfad75900e6681ffd7150

After we created the scenarios we need to forward inbound calls to our virtual number to our scenario for processing. It can be done while editing the application https://manage.voximplant.com/#editApplication at Rules tab — click Add rule button

Add the following rule (which will forward all inbound calls to our scenarios for processing)

Now if we call one of phone access numbers(in US it is +19292240694) and enter the virtual number we have bought earlier (699100053 in my case) our call will be forwarded to our xwiki + voxbot scenarios for processing (they will be concatenated during the execution). Give it a try, ask who are the founders of Google or who created Facebook and so on.

P.S. You can use any sandbox phone number from the list to test the service: +74993504126 (Russia), +19292240694 (US), +48223970842 (Poland), +81345790139 (Japan), +390694500414 (Italy), +97243720980 (Israel), +420228880669 (Czech Republic), +14388002812 (Canada), +61283104145 (Australia), +442038083060 (UK). Don’t forget to enter 699100053 after call is connected.

--

--