Scale customer reach and grow sales with AskHandle chatbot

Discontinuing a Session in Dialogflow ES

Dialogflow ES (Enterprise Edition) is a platform for building chatbots and voice assistants. Sometimes, you may need to end a session due to user requests or system requirements. This article explains how to gracefully end a session in Dialogflow ES.

image-1
Written by
Published onOctober 4, 2024
RSS Feed for BlogRSS Blog

Discontinuing a Session in Dialogflow ES

Dialogflow ES (Enterprise Edition) is a platform for building chatbots and voice assistants. Sometimes, you may need to end a session due to user requests or system requirements. This article explains how to gracefully end a session in Dialogflow ES.

Ending a Session in Dialogflow ES

To end a session in Dialogflow ES, you can use the "endInteraction" event. This event allows you to terminate the conversation and provide a final response to the user. Triggering the "endInteraction" event indicates that the conversation is complete and the session can be safely terminated.

Implement the "endInteraction" event in your Dialogflow ES agent through fulfillment code in your webhook or inline editor. Here is an example using Node.js code to end a session:

Javascript

In this code snippet, the endSession function adds a farewell message to the agent's response and then calls endInteraction to terminate the session. You can customize the farewell message as needed.

Handling Session Discontinuation Scenarios

You may face different scenarios where discontinuing a session is necessary. Here are two common situations and how to handle them.

User Request to End Session

Users may express a desire to end the conversation. For example, a user might say "Goodbye" or "I'm done." Create an intent in Dialogflow ES to capture these expressions and trigger the "endInteraction" event.

To set up an intent for user requests to end the session:

  • Create a new intent and name it "endSessionIntent."
  • Add training phrases like "Goodbye," "I'm done," or other expressions users might use to indicate the end of the conversation.
  • Enable fulfillment for the intent and link it to the endSession function created earlier.

System-initiated Session Termination

You may need to terminate a session due to specific system conditions. For example, you might have a time limit for each session or need to end a session after completing a task.

To handle system-initiated session termination, add logic to your fulfillment code to check these conditions and trigger the "endInteraction" event as necessary.

If you have a time limit of 10 minutes for each session, use a timer or set a timestamp when the session starts. Periodically check the elapsed time in your fulfillment code. If the time limit is reached, call the endInteraction method to terminate the session.

This article explained how to discontinue a session in Dialogflow ES. The "endInteraction" event allows for graceful conversation closure. You also learned to handle both user requests and system-initiated terminations.

Effective session management enhances the user experience of your Dialogflow ES-based chatbot or voice assistant. Implement the appropriate logic in your fulfillment code and customize farewell messages for smooth conversation closure.

Create your AI Agent

Automate customer interactions in just minutes with your own AI Agent.

Featured posts

Subscribe to our newsletter

Achieve more with AI

Enhance your customer experience with an AI Agent today. Easy to set up, it seamlessly integrates into your everyday processes, delivering immediate results.