Automatic spell correction is available in Dialogflow API v2

2020 Update: It has been a while since I wrote this post. I have also confirmed with clients, and I can say that the autocorrect is now quite reliable. So you should use the feature, but remember that you don’t get the original query with the typo in the History and Training.

Recently, Dialogflow made an important improvement to their service. They provide automatic spelling correction if there are typos in the user’s message.

How to enable the feature

First, make sure you are using an agent which is on API v2.

Next, go to Settings > ML Settings and enable the Automatic Spell correction toggle.

How it works

So let us take a look at how well it works.

Regular (non-entity) words

Example 1: I introduce a typo in the Dialogflow simulator for a regular (non-entity) word.

And Dialogflow is able to correct the spelling and produce the expected result.

Entity values

Can Dialogflow help with spell correction of entity values too? Apparently, it can, but I found the behavior a little unpredictable.

Here is the entity element:

Example 2: Here, I introduce a typo in the word Carbon.

Which isn’t identified:

Example 3: Then I introduced another typo:

Which is corrected:

Should you start using the feature?

Personally, I am not sure if it is ready for production use.

Specifically, here are my concerns:

The entity autocorrect is not predictable

As you have seen above, it seems like there are some cases where the entity value is automatically corrected to the right spelling. But it doesn’t happen always, and the rules for when the spell correction gets triggered isn’t apparent.

There is no way to know if spell correction happened

It would be super useful to have a true/false value which specifies if some spell correction did happen.

In the best case, Dialogflow was correct, and you would still want to find out the mis-spelling, say if you want to add it to your own internal knowledge base or internal search engine. In the worst case, Dialogflow made a mistake and you can use it to decide if you want to turn the feature on/keep it turned on.

Even if the autocorrect feature isn’t turned on, Dialogflow can successfully map the intent on certain kinds of typos already (you can go and check this for yourself by omitting a vowel from a long-ish word). So having this data available will allow the developer to distinguish between the following scenarios:

  • user made a typo, automatic spell correction wasn’t turned on, but Dialogflow got the mapping right
  • user made a typo, automatic spell correction was turned on, Dialogflow got the mapping right because autocorrect was on
  • user made a typo only in non-entity word, automatic spell correction was turned on, Dialogflow got the intent mapping right because of autocorrect
  • user made a typo only in the entity word, spell correct was on, Dialogflow failed to get the intent mapping right (example 2 above)
  • user made a typo only in entity word, spell correct was on, Dialogflow got intent mapping right (example 3 above) and extracted the entity value

It is possible I don’t have the exhaustive set of scenarios covered here, but hopefully you get the picture. Having knowledge of whether any spell correction was done will allow the developer to get a lot more insight into how Dialogflow works.

So my suggestion is to use it for your test agents at the moment, and then turn on the feature in your production bot once you have a good understanding of the overall effect of the spell correction.


About this website

I created this website to provide training and tools for non-programmers who are building Dialogflow chatbots.

I have now changed my focus to Vertex AI Search, which I think is a natural evolution from chatbots.

Note

BotFlo was previously called MiningBusinessData. That is why you see that watermark in many of my previous videos.

4 Comments

Leave a Reply