I have recently had a few clients bring up an odd issue in Dialogflow.
When you "Click to Assign" an intent from the Training tab, sometimes the question/message from the chatbot user has some special characters which can then prevent you from saving your Dialogflow agent, leading to some kinds of obscure warning messages. More importantly, you are now unable to save the changes you made. And to make matters worse, you are usually not able to even understand exactly which intent is causing this issue.
It seems there is a combination of factors which causes this issue:
- you have set up the Google Assistant integration
- in addition, you have also set up integrations with other channels such as Skype
- you use "Click to assign" to add the training phrase to an intent
- when you save, this new training phrase is incompatible with the Google Assistant's schema for some reason, and the agent will not allow you to save
Here are some tips for handling this issue:
1 Use versioning
You might have seen the new versions and environments feature in Dialogflow. So a simple idea is to save a new version just before you start the training, and then if the training throws an error you can revert back to the old version. You need to be on v2 API to be able to do this.
The use of versioning and environments is an entire topic by itself. But the basic idea is that you are also going to be doing your training only within your test environment, which means you should have created a test environment for your agent to begin with. I plan to write some tutorials about this in the future, but for now just remember that you have this option, before you start doing your training.
2 Do a save after adding each phrase
This of course slows down your workflow, but if you do a save after each new training phrase you add from the Training tab, you can catch the error right away. The advantage is that you don't end up trying to do a Save after you have already added a whole bunch of training phrases - this means you know exactly which phrase caused the problem.
3 Avoid adding training phrases which contain special characters directly
One of the things you will notice is that it is often special characters such as apostrophes and ampersands which seem to cause these kinds of issues. So if you notice these characters in the Training tab, you can also avoid adding those directly from the Training tab. Instead you can do one of the following things:
3.1 Type it out by hand into the appropriate intent
The simplest thing to do in this situation is to simply type out the phrase by yourself into the intent. This is the perfectly safe option. Also, it shouldn't be too much effort because usually you are only dealing with fairly short phrases in Dialogflow
3.2 Copy to Notepad first, and then paste it into Dialogflow
Another option which helps is to copy the training phrase into Notepad (or similar text editor for Mac) and then paste it into Dialogflow. This can sometimes strip out some of these special characters. However, it is not as reliable as simply typing out the phrase into the intent's Training phrases section by hand
4 You forgot to do all this, and you cannot save your agent now
So you were not aware of this problem, and you have already added a whole bunch of training phrases. You also didn't set up versions. Now you are unable to save your agent and you are getting the Schema error. Or perhaps a similar error which vaguely points to a training phrase.
Since you cannot search across intents in Dialogflow, you are not sure how you can find the offending phrase. You can use my Dialogflow Navigator app to search for the offending training phrase. Also be sure to read my article describing the error which will give you some additional tips for solving the problem.