Slot filling
Context Lifespan
Conversation Design
Bot frameworks
Machine Learning

The context lifespan is like a “hidden feature” in Dialogflow

The context lifespan you set for an output context is like a “hidden” feature. I mention this because I still see this issue for many people who come to me for help with fixing their Dialogflow chatbot. But I notice they don’t use a lifespan of 1. To make things worse, quite often they don’t see the connection between using the default lifespan and the unpredictable behavior of their chatbot.

In this article, I will point out some benefits of rigorously following a context lifespan of 1.

Why use a context lifespan of 1

So if you have been following along till now, you will see that a context lifespan of 1 provides many benefits as you are designing your chatbot.

1 Understand your chatbot’s behavior completely

When you understand your chatbot’s candidate, target and surplus intents at each step in the conversation, you are going to have a much better understanding of your chatbot, period.

2 Build more complex dialogs

Sure, you cannot yet build a chatbot that can actually talk like a human (unless you wish to end up with a Tay).

But you CAN build fairly complex dialogs if you are able to better guide the conversation along a given path.

3 Better fallback handling

When you don’t get the expected input from a user, you can reprompt them in a more sensible way (note: slot filling is not a very sensible way of reprompting users for input).

4 Better input validation

Closely tied to the previous point, you can validate the input on your backend and do a better job of guiding the conversation if you strictly use a context lifespan of 1.

5 Create a library of conversation patterns

Understandably, design patterns are sometimes ridiculed.

But when a subject is fairly new (such as building chatbot dialogs), having a library of patterns you can understand and reuse (synergy:management::reuse:programming) is quite helpful.

You can also create a library of these conversation patterns without using the context lifespan of 1. But you will have a hard time managing the behavior.

Example of patterns:

  • input validation
  • reprompt for input
  • slot filling (the concept, not the feature)
  • getting multiple inputs from the user

6 Create chatbot building blocks

Once you actually define a few conversation patterns, you will be able to combine them (once again, very hard to do if you don’t enforce the context lifespan = 1 constraint).

What does this mean?

It means you can start programmatically generating your agent’s intents. For example, creating a chatbot which should take a set of user inputs and can also do intelligent input validation and error re-prompting can be done using predefined templates. (Would you be interested in a course about the topic? Let me know in the comments below. If I get at least a handful of comments, I will get to it sooner).

Generic filters