Still updating your Dialogflow agent manually? In this post you're going to learn how to use the Jovo CLI and Dialogflow v2 API to deploy a Dialogflow agent from your command line.
- Step 1: Updating to the Dialogflow V2 API
- Step 2: Setting up Authentication
- Step 3: Deploying your Agent with the Jovo CLI
You can also watch the full process of creating a Jovo project and a Dialogflow agent, and deploying it with the CLI in this video (for the deployment part, feel free to skip to minute 12:20):
Making changes to Dialogflow (the natural language understanding platform that is used for Google Assistant projects in Jovo) can be tedious if you want to keep it up to date with the Jovo Language Model. Usually, you have to do one of the following in the Dialogflow Console:
- Update the language model manually
- Use the _dialogflowagent.zip file created with jovo deploy to RESTORE your existing Dialogflow agent in the preferences:
Can become quite annoying, right?
Finally, you can use the command line to update your Dialogflow agent! Since Jovo v1.0, we support the Dialogflow v2 API which allows you to set up an authentication for programmatic deployments. There are a few manual steps we need to do first, so let's get started.
First of all, go to the Dialogflow console and click on the gear icon right next to your agent's name to get to the settings tab:
On the bottom of the page you can find the toggle for the V2 API. The system will ask you, if you're sure, that you want to change the API version, since the request and response format will change, but no worries, the Jovo framework can handle both the V1 and V2 API.
That's it! Now we need to set up the authentication to be able to access the Dialogflow agent programmatically.
After saving the changes (Dialogflow v2 API), you will find a service account right beneath the project ID:
It will lead us to the Google Cloud Platform, where we will create a new service account using the button at the top of the page:
Dialogflow API Admin as the role:
After that we create a new
Last but not least move the key file to our project's root folder.
The Jovo CLI uses the Google Cloud SDK to access Dialogflow through projects on the Google Cloud Platform. You can download it here.
Install the SDK and initialize it using the quickstart guide from Google.
After that add both the
projectId of your Dialogflow agent and the path to the
keyFile to your project's
Now run the build and deploy command and your agent will be updated:
The result should look like this: