Wednesday, October 20Digital Marketing Journals

Making chatbots reply smarter with context using Dialogflow Fulfillment | by Rensen Ho | Sep, 2021


1. Instead of one intent with the required slot filling parameters, create that intent followed by one intent for each parameter. (See purple boxes above)

2. In those intents with a single slot filling parameter, set it optional.

3. Put all entities extracted from any intent into the conversation context programmatically. (See the blue box above)

4. Make a functional response for a group of related intents (see the orange box above), so that you’re making a chatbot to reply based on the user’s intent and information (either mentioned or referred from context), instead of intent without information.

Let’s take a closer look at the code.

Start by creating a map of intents. Let the agent (a webhook client) use the intent map to handle incoming messages.

Remember to create those intents in Dialogflow and turn on the webhook fulfilment.

Next, for each intent that acts on the customer’s query (such as the ticket price inquiry in this case), the chatbot will reply based on the number of participants (children, adults and seniors), the site they wish to visit, and the citizenship.

  1. Extract both the slot filling values (parameters) and the context parameters found in the request body.
  2. If the customer has explicitly mentioned the site, the number of people and/or their citizenship, use that. If not, recall from the context in the current conversation session.
  3. Make a functional reply using those parameters, such as replyTicketPrice(agent, citizenship, participants, site) .
  4. Finally, keep all (and new) parameters mentioned in the context.
    agent.context.set({name, lifespan, parameters: { …currentParams, …newParams}}) This is helpful when the bot goes back to step 1 and 2, preventing the user from repeating the details.
  5. In many cases, a chatbot is designed to fulfil a wide range of customer requests, so a good idea is to assign a topic name in the context to keep the current conversation relevant (be it about ticket price inquiry, membership registration or something else) in case the user informs the chatbot about a different site or a different number of visitors.

1. How Conversational AI can Automate Customer Service

2. Automated vs Live Chats: What will the Future of Customer Service Look Like?

3. Chatbots As Medical Assistants In COVID-19 Pandemic

4. Chatbot Vs. Intelligent Virtual Assistant — What’s the difference & Why Care?

So how should the bot exactly reply? There are 8 possible ways to reply, based on what parameters were given, and it’s up to your conversation design.

If the customer comes with a short and sweet message like “ticket prices”, the chatbot will ask for one of the required parameters. Or if the customer says “ticket prices to the cloud forest”, there’s an equal chance that the bot will ask for the number of the participants or the citizenship. All bot replies are in the form of questions, which will elicit a relevant answer from the user, otherwise, the bot will tell the customer the ticket prices right away if all are known.

What happens when the user says “2 adults, 1 child”, “cloud forest”, or “tourist”? The respective parameter-based intent is triggered, not the ticket price intent. In this situation, the chatbot will invoke the replyTicketPrice response based on whatever information is passed to it each time. There is also the possibility that the customer starts talking to the chatbot that they are “interested to visit” without a specific purpose like inquiring about the ticket prices, so the bot may ask “Which site?”.

The fulfilment of this parameter-based intent (site) shares the same design pattern for the other two (participants and citizenship).

Context is a great way to carry important details from intent to intent, especially if the customer changes information, interrupts the flow by going off-topic, or wants the bot to complete multiple requests.

Leave a Reply