1. Home
  2. Docs
  3. Tutorials
  4. Build a Phone Assistant

Build a Phone Assistant

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.

Conversation.one is a build-once-deploy-anywhere platform, where your app can be deployed as an Alexa skill, Google Home action, Facebook Messenger bot, or a chatbot on your website

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") {
        res.card({
            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;
        res.card({
            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:
    • (connect|transfer) me to (|your) {Leader}
  5. Add entities:
    • PhoneNumber – Type PhoneNumber
    • Leader – Create new custom entity named “Leaders” with the values:
      • leader
      • orly
      • rachel
      • chen
  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:
    • (|my number is|my phone number is|my mobile number is| my mobile is) {PhoneNumber}
  5. Add entities:
    • PhoneNumber – Type PhoneNumber
  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.

You can test a pre-created app by calling +1 646-362-1150 and typing “5283” as your app id

What’s next?

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

Was this article helpful to you? Yes No

How can we help?