3 Ways spaCy can help improve Dialogflow accuracy

spaCy is a free open-source library for Natural Language Processing in Python.

You can use it to improve the accuracy of your Dialogflow bots.

This is somewhat advanced material, and also requires that you already have a Python programmer on your team who is familiar with the basics of Natural Language Understanding (NLU)

Automatically group chat logs into intents

You can do the verb.noun analysis I describe here to automatically group your chat logs into Dialogflow intents. It uses the spaCy dependency tree feature to extract sentences in the format specified.

This can be especially helpful if you have a lot of chat logs and you are trying to sort/cluster them without manually spending a lot of time. Even though the automatic grouping can help a little, you still need to do some manual work to finish the process.

This can improve the accuracy of your Dialogflow ES bot by making sure you are creating intents that help Dialogflow’s existing ML algorithm. To understand why, I recommend going through this article.

Autogenerate test scripts from training phrases

You can run automated conversation tests to ensure that your chatbot is working as expected. This is important because any change you make to your training phrases has the potential to break existing behavior.

The easiest way to generate test scripts is to parse your existing training phrases and programmatically add a filler word at the end. spaCy makes it easy for you to do this.

I explain the idea in this video.

Improve training phrase quality

Dialogflow matches user utterances to existing intents.

During this process, it provides an “intent detection confidence” score.

You can use spaCy to analyze all user utterances and see if you can identify patterns in the utterances which get very low confidence scores. In turn this will help you choose better training phrases for your chatbot.

When Dialogflow matches a user utterance to an intent, there are four possible outcomes: true positives, true negatives, false positives and false negatives (defined here).

We don’t care much about true positives and true negatives, although they can be useful for conversation testing.

To figure out false positives and false negatives, you can do some basic NLU analysis of your user utterance and try and see why the mapping failed. This will give you a lot of insight into what is happening under the hood.


About this website

BotFlo1 was created by Aravind Mohanoor as a website which provided training and tools for non-programmers who were2 building Dialogflow chatbots.

This website has now expanded into other topics in Natural Language Processing, including the recent Large Language Models (GPT etc.) with a special focus on helping non-programmers identify and use the right tool for their specific NLP task. 

For example, when not to use GPT

1 BotFlo was previously called MiningBusinessData. That is why you see that name in many videos

2 And still are building Dialogflow chatbots. Dialogflow ES first evolved into Dialogflow CX, and Dialogflow CX itself evolved to add Generative AI features in mid-2023