You can do version control and CI/CD with Dialogflow. Although it may look like Dialogflow is not created for developers, you can set up a nice developer flow. This makes it possible to scale development to a team of developers. This article will show you the best practices for an effective development process.

When you start off using Dialogflow you can get a user friendly web interface. You can program phrases that your voice assistant should support. Even though the Dialogflow interface is useable by non programmers, you are still programming. For a software developer it is important to have access to the source code of what they’re programming.

The Dialogflow web interface

The Dialogflow web interface

Version Control

Having source code in version control makes it easy to do rollbacks and review changes from other teammembers. By default you use the Dialogflow UI to configure your various intents. However there is no version control, just import / export functionality. You have to manage the exports manually to be able to do rollbacks.

Dialog Import Export

Dialog Import / Export

Fortunately there is a community developed CLI tool. This allows you to use the import / export functionality from the commandline. It exports to readable JSON files. This means you can make edits in the web UI and export these to a local folder which is under version control. You can then manage the versions locally and import those into Dialogflow again using the CLI tool. Once you understand the JSON files from the export, you can even edit them locally and import the changes into Dialogflow without having to use the web UI at all.

It seems likes Google is doing this when they are developing for Dialogflow. Google developed a Google Assistant app for their Google I/O 2018 event. Since their source code is on GitHub, you can see that they are exporting Dialogflow to Git. Have a look at the dialogflow-agent folder in the repository. Google has not released the tool they are using to do the import / export. I can imagine this will be functionality which is eventually added to the gcloud CLI tool.

To install the community developed CLI tool you need to have NodeJS and NPM installed. Because the tool needs access to your Dialogflow project you need to provide it with credentials to your project as well. Be careful not to commit your credentials to version control though. Not everyone who has access to your sourcecode should have admin access to your Dialogflow project.

To install the CLI tool run the following commands:

Working in teams

Now you have your dialogflow configuration in version control you can do rollbacks and code review. You can create pull requests to code review or look at the diffs manually. You can also have multiple team members work in parallel on different branches and merge their changes.

To be able to export only your own changes you need to make sure that each team member has their own dialogflow project. Otherwise you might export changes from another teammember to your version control branch. If you want to deploy to a staging or production environment you can use a different credentials. The credentials.json file are tied to a Google Cloud project which can only have a single Dialogflow project.

To be able to run the scripts easy you can create NPM run scripts:

You can run these commands like so:

To help out your current and future team members it is good to document this process somewhere.

Continuous Integration and Deployment

To run on a build server you need to configure the credentials. You can put the credentials in a (protected) environment variable and export that to a file.

Now you can configure your pipeline to deploy manually or automatically to different environments.

Conclusion

Once you can tread your Dialogflow configuration just like any other code, it integrates nicely with existing development flows. Now you can scale development like you’re used to.