Creating Conversations for Google Assistant


Before we begin building the app, lets understand what an invocation is. Invocations are used to invoke or select the action you want to talk to. There are two types of invocations:
Explicit Invocation This is when the user explicitly tells the Assistant they want to talk to a particular action. For example, “Hey Google, talk to Random Words”.

The Welcome Intent

The Welcome Intent is the first intent that gets invoked when a user wants to talk to your Action. In this section, we will modify the default welcome intent, so that it greets the user and asks for his/her favorite day of the week.

  1. In the intents page of the Dialogflow console, click on Default Welcome Intent.
  2. Under the Responses section, delete all the default responses, by clicking the trash icon next to it.
  3. Now click on Enter a text responsee and type "Welcome! What is your favorite day of the week?".

Create your own Intent

  1. In the Dialogflow Console, in the left navigation, click on Intents and then click on Create Intent.
  2. Name your intent “favorite day”, in the name field at the top.
  3. Under the Training phrases, add a few examples of how the user might express this intent. The examples you provide are used to train a machine learning model which allows the agent to match future inputs to the appropriate intent. Here we will add the following examples:
  • My favorite day is Saturday
  • I like Friday
  • I love Monday
  • Sunday is my favorite
  • Wednesday
  1. Now Dialogflow should automatically pickup the day name in the training phrase, and highlight it. Under Actions and parameters you should also see a new parameter is added called date. Parameters represents values that you want to extract from the user's phrases. It is basically like a variable, that dialogflow automatically extracts from the training phrase. Here the parameter is date and we will use its value extracted from the user, to determine the lucky number and give back a response.
  2. Check the Required box of the date parameter. A new column called Prompts will show up. Click on Define prompts and enter "What is your favorite day?" as a prompt. You can also add multiple variants of the same question in the prompts. We define this prompt because we cannot move any further without having the date parameter. So by any chance, if Dialogflow was unable to extract the date parameter from what the user said, it will explicitly ask the user for a value for the parameter.


  1. Now skip the Responses section, since we will be calculating the response based on the date parameter. Under the Fulfillment section, turn on Enable webhook call for this intent. This allows the response to the user to be dynamically generated. This is done by passing the parameter value to a function, where we write the logic to construct a response for the user. This function is run in the cloud. Click on Save to save this intent.
  2. In the left navigation, click on Fulfillment. Enable the Inline Editor. We will write the logic for our function here.
  3. Replace the code in index.js with the following:
  • A Dialogflow Conversation object - This is a client library abstraction of the state of the dialog, and includes properties which represent values of the incoming request to our webhook, such as the current active dialogflow contexts, the surface capabilities of the user device, etc..
  • A Dialogflow Parameters object - This is a JavaScript Object representation of the parameter values collected in the related intent. Here the parameter object was date.

Testing your Actions

  1. Open the Actions Console and select your project. Click on Simulator in the left navigation.
The app in action !



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adarsh Menon

Adarsh Menon

I make websites and teach machines to predict stuff. I also make YouTube videos —