How to use Context with Dialogflow to handle errors (Part 2: Knock Knock, It’s me)

How to use Contextual Fallback with Dialogflow to handle errors (Part 2: Knock Knock Jokes)

(This is Part 2 of a four-part series on how to use Context with Knock Knock jokes. You can find Part 1 here.)

In Part 1, I demonstrated how you can use Context in Dialogflow to build a simple Knock Knock joke. In Part 2, I will show you how to handle unexpected responses using contextual fallback.

Situation: User does not reply “Who’s There”

Some people will mistype. Other jokers may want to mess with your bot and not respond correctly.

So how do we deal with this?

  1. To trigger a prompt to say “who’s there”, create a fallback intent.

Top 3 Bot Tutorials

1. Dialogflow Restaurant Chatbot Tutorial

2. Dialogflow Restaurant Chatbot Tutorial | 1

3. Dialogflow Restaurant Chatbot Tutorial | 2

4. AI & NLP Workshop

2. Add input context “knockknock”.

This means that this fallback will only be triggered if the bot does not understand the response AND the user is within the context of a knock knock joke.

3. Add output context = knockknock with lifespan of 1. This maintains the context of the knock knock joke and is a necessary condition to trigger the “Who’s There” intent, if the user replies “who’s there” after being prompted.

4. Add your response.

As you can see from the image below, we need to have output context in order for the “who’s there” intent to trigger a response.

If I remove the output context, the knock knock context is lost, and “who’s there” will trigger the default Fallback.

Do note that this will only work for responses that the bot does not understand. If you say something that the bot is trained to answer (e.g. “hi”), it will trigger that intent instead. This is important as it allows the user to exit the flow of the knock knock joke whenever he wants.

Only when the bot does not understand will it trigger the contextual fallback instead of your default fallback.

In the next tutorial

In Part 3 of this Tutorial, we will cover situations where users try to be clever and spoil your punchline! Here’s a sneak peak!

You can find Part 3 here.

Download the Dialogflow agent

You can download the Dialogflow agent here!

Other Tutorials In this Series

Part 1: How to use Context to build simple Knock Knock Jokes

Part 2: How to use Contextual Fallback to handle errors

Part 3: How to use Context when users try to spoil your punchline

Part 4: How to use Context and Entities to respond to users’ Knock Knock Jokes

How to use Context with Dialogflow to handle errors (Part 2: Knock Knock, It’s me) was originally published in Chatbots Life on Medium, where people are continuing the conversation by highlighting and responding to this story.

Source link

Related posts

Facebook Research at CVPR 2019


Julia Lab joins team to speed up drug approval process


MPhil-PhD transfer – Simon Odense – 30 Nov, 12noon, EM01


This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Privacy & Cookies Policy


COVID-19 (Coronavirus) is a new illness that is having a major effect on all businesses globally LIVE COVID-19 STATISTICS FOR World