Build your own voicebot in flat 27 minutes

As a chatbot enthusiast, i strongly beleive that chatbots should interact with us like a natural human. Not a like machine that throws some options at you and ask to choose one.

The whole idea of Natural language processing (NLP) is to be able to converse with machines like we do with our dudes. And a slight extention of this is to be able to talk to them using our voice and not typing.

I dont type and talk to any of my dudes when i meet them in person. We are already having now voice based assistants like Alexa, Siri and Google assistant. Lets now DIY, our own voice based assistant.


Before diving into building the bot, there are few things you need to keep handy

  • You must have created an account on Dialogflow
  • Node.js installed on your local machine
  • ngrok installed on your local machine

Here we are going to build a sample voice bot, which will allow users to order mobiles through google assistant on their phone. The main focus here will be how to connect dialogflow with google assistant and write a webhook for it.

Step - 1

Create your Agent on Dialogflow

  • Login to console.dialogflow.com and click on 'Create new agent'
  • Provide the agent name, choose default language and your time zone and click on create
  • First let's add the entities (i.e mobiles). Click on entities and create a new entity named 'mobiles' and populate with all the mobile names. You can also populate entities by uploading json or csv files.
  • Now create a new intent 'OrderMobiles' and add few training phases. Make sure you include number of mobiles and mobile name in each phase as shown.
  • Under Action and parameters make number and mobiles as required parameters and add the corresponding prompt text for it.
  • Let's add the response 'Do you want to add more products to your cart ?'

Step - 2

Add Follow-Up intents

  • Add a follow-up intent and choose 'yes' from the drop-down list.
  • Make sure the output context of this intent is the input context for 'OrderMobiles'
  • Under fulfillment make sure to enable webhook call for this intent
  • Create another follow-up intent for 'OrderMobiles' and choose 'no' from the drop-down list
  • Similarly enable webhook call for this intent as done earlier
  • And under response slide-on 'Set this intent as end of conversation'
  • Step - 3

    Enable Google Assistant

    • In your dialogflow console, navigate to 'integrations' and click on Integration Settings
    • Click on 'Test'
    • This will redirect you to google assistant simulator, make sure you enable 'Web & App Activity'

    Step - 4

    Setup the Node.js server

    • Create a new node app using express
    • Create a '/webhook' post request end point
    • Using ngrok create a https url for the your node app
    • Copy the https url and navigate to Dialogflow and thereby click on fullfillment
    • Enable the webhook and paste the url (eg. URL* https://6629d660.ngrok.io/webhook) and save it

    That's it, we have successfully connected our Dialogflow and Google assistant using webhook. You can then perform your back-end under queries '/webhook' and response back with desired answers.

    Here is the final video: