Setup a new project in Google assistant and follow the basic on-screen information. Not much to do at the moment in this console, You can use it in the end to publish your Assistant. All you will need is the Privacy policy text, and a logo icon.
You’ll be asked to fill in some more information about the type of the project you are creating.
Let’s jump to define our first Intent.
- Select a name for your intent which we will use in our webhook (cloud function) to be triggered. e.g. “get apples”
- Set Training phrases, to define how your users will trigger this action. For example “how many apples do I have?”
- An interesting field is the Actions and parameters.
Here you will define how the value will be passed in your script from the user. The name of the action can be set here, alongside the params you expect your user to give you.
If the param is missing from their request, you can define what the followup questions will be from the Agent. (last table column).
Required — self explanatory
Parameter name — will be parsed from the fulfilment scripts as agent.parameters.color
Entity — you can define here what type of data you’re expecting, seems we have color as a System entity to pick.
Value — you can set the initial value as placeholder. More information here
IsList — self explanatory
Prompts — A great way to define how the Agent will ask for each value if it’s not provided initially
more about the actions and parameters, here
- Lastly you need to enable webhook in the fulfilment section, which will enable the use of the deployed Cloud Functions
Enable your database and create your documents (Assuming you already have a platform running, you have data, and maybe even a different storage service.
For our example we are using Firestore, that looks like this
Now we are ready to bind the pieces together. All you need to do is to setup the Fulfilment. We enable the cloud functions which will automatically deploy and link the function, ready to consume.
2. Smart Chatbots and Virtual Assistants are Coming!
To access the database form the function you’ll need to load the firebase-admin as seen here.
The Function editor within the Dialogflow Fulfilmen
const admin = require(‘firebase-admin’);
admin.initializeApp(functions.config().firebase);
const db = admin.firestore();
The configuration setup is done for you, and the projects are linked altogether. All you need to do now is to grab your collection and start reading data.
const applesDoc = db.collection(‘apples’)
Add the handler for your intent. Use the intent’s name set earlier.
intentMap.set(‘get apples’, getApples);
Define the handler:
All you need to do now is to deploy and test. You can define environments and try a few ways to test, and view logs. The information in the dashboard, is pretty clear to follow from this point on.