Over a million developers have joined DZone.

Hello Alexa: Build a Conversational Phone Assistant

DZone's Guide to

Hello Alexa: Build a Conversational Phone Assistant

Learn to develop a conversational phone bot that can create a useful and natural interaction with clients with this code-heavy tutorial.

· AI Zone ·
Free Resource

Did you know that 50- 80% of your enterprise business processes can be automated with AssistEdge?  Identify processes, deploy bots and scale effortlessly with AssistEdge.

We all love talking to Amazon Alexa and Google Home, but what happens when we are away from home or our desk? With Conversation.one you can develop a Conversational Phone Assistant, which provides a comparable experience to Amazon Alexa and Google Home, but on the phone. Your users would be able to call a dedicated phone number and ask for information using a flexible natural conversation.

In this example, you'll build a basic "phone directory" conversational application that will transfer the user to the requested name. A conversational app is essentially the container or project and it contains intents, entities, and the responses you want to deliver to your user. Intents are the mechanisms that pick up what your user is requesting (using entities) and direct the app to respond accordingly.

Create a Conversational App

A Conversation.one application represents your conversational interface through Amazon Alexa, Google Home or Facebook Messenger bot. To create an app:

  1. If you don't already have a Conversation.one account, sign up. If you have an account, log in.
  2. Click on Create New App in the navigation. If it's your first application, you will be redirected to the Create New App wizard automatically.
  3. Select your industry and enter your company name. For the purpose of this tutorial, select "Other" for the industry. Click Next to continue.
  4. Enter "Phone Directory" as your company name. Click Next to continue.
  5. Select the devices you want to support with your app. For this demo select Phone and Chatbot. Click Next to continue.
  6. Your new application is ready. Click Customize to start developing your app.

Create an Intent

An intent maps what a user says with what your app does. This intent we will create now will be invoked when the user asks to be transferred to one of the options in our directory.

To create an intent:

  1. Click "Create a new intent"
  2. Enter "Transfer Me To Your Leader" as the question. Click Next to continue.
  3. Select Code response. and enter the code below:
    var directory = {
        "chen": {
            "fullName": "Chen Levkovich",
            "image": "https://s1.mob-server.com/files/5282/chen.jpg",
            "phone": "+18452689922"
        "rachel": {
            "fullName": "Rachel Batish",
            "image": "https://s1.mob-server.com/files/5282/rachel.jpg",
            "phone": "+15703870000"
        "orly": {
            "fullName": "Orly Frank",
            "image": "https://s1.mob-server.com/files/5282/orly.jpg",
            "phone": "+19164400031"
    var leaderName = req.slot("Leader").charAt(0).toUpperCase() + req.slot("Leader").toLowerCase().slice(1);
    if (leaderName.toLowerCase() === "leader") {
            type: "Standard",
            title: "Our Leader",
            text: "We come in peace",
            image: {
                smallImageUrl: "https://s1.mob-server.com/files/5282/alf.jpg",
                largeImageUrl: "https://s1.mob-server.com/files/5282/alf.jpg",
        res.say('I will transfer you to our leader');
        res.say('<audio src="https://s1.mob-server.com/files/5282/ie_Short_Cow_MooDTMF_Tones-KevanGC-494166652.mp3" />');
        return res.say('<audio src="https://s1.mob-server.com/files/5282/APOLLO_11_President_Nixon_Phone_Call.mp3" />');
    var targetPhoneNumber = "+14128850075";
    if (leaderName.toLowerCase() in directory) {
        targetPhoneNumber = directory[leaderName.toLowerCase()].phone;
            type: "Standard",
            title: directory[leaderName.toLowerCase()].fullName,
            text: directory[leaderName.toLowerCase()].fullName,
            image: {
                smallImageUrl: directory[leaderName.toLowerCase()].image,
                largeImageUrl: directory[leaderName.toLowerCase()].image,
    } else {
        res.say("Sorry, I don't know " + leaderName + ".");
        res.say("I will connect you to the operator.");
        leaderName = "the operator";
    if (req.getChannel() == "phone") {
        res.say('I will transfer you to ' + leaderName);
        res.say('<audio src="https://s1.mob-server.com/files/5282/ie_Short_Cow_MooDTMF_Tones-KevanGC-494166652.mp3" />');
        return req.setRedirectToPhonecall(targetPhoneNumber);
    if (!req.slot("PhoneNumber")) {
        return sdk.conversationHelper.askForEntity(context, req, res, [
                "name": "PhoneNumber",
                "target": "PhoneNumber"
        ], "To connect you with " + leaderName + ", I will need your phone number. What is it?", 'For example you can say, My Phone Number is <say-as interpret-as="telephone">6467080983</say-as>');
    res.say('I will connect you to ' + leaderName + " now.");
    res.say('<audio src="https://s1.mob-server.com/files/5282/ie_Short_Cow_MooDTMF_Tones-KevanGC-494166652.mp3" />');
    return sdk.twilloCall(req.slot("PhoneNumber"), targetPhoneNumber);
    Click Finish.
  4. Open the new intent. In the User Says section enter the example below:
  5. Add entities:
    • PhoneNumber - Type PhoneNumber
    • Leader - Create new custom entity named "Leaders" with the values:
  6. Click Save to apply your changes

Add Phone Number collection intent:

  1. Click "Create a new intent"
  2. Enter "EnterPhoneNumber" as the question. Click Next to continue.
  3. Select Code response. and enter the code below:
    return sdk.conversationHelper.FillEntity([{
     "name": "PhoneNumber"
     }], context, req, res);
    return sdk.twilloCall(req.slot("PhoneNumber"), targetPhoneNumber);
    Click Finish.
  4. Open the new intent. In the User Says section replace the example with the one below:
  5. Add entities:
  6. Click Save to apply your changes

Try It Out

Now that your app can transfer the users to the different employees, try out what you have so far.

In the chat console on the right, type in a request. The request can be a little different than the examples you provided in the User Says section. This can be something like, "Transfer me to Rachel." After you type the request, hit "Send".

The chatbot will answer ask for your phone number and will transfer you to Rachel.

To test your new Conversational Phone Assistant, call +1 646-362-1150. The system will you to provide your App ID, you can find it in the editor URL, or under the app settings page. One you provided your application ID, you can start talking to your app.

What's Next?

Feel free to contact us; we are happy to help and answer any questions you may have.

Consuming AI in byte sized applications is the best way to transform digitally. #BuiltOnAI, EdgeVerve’s business application, provides you with everything you need to plug & play AI into your enterprise.  Learn more.

ai ,building ,conversational bot ,phone assistant ,alexa ,google home ,intent

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}