Friday, March 14, 2025

Utilizing Dialogflow CX To Develop A Self-Escalating Chatbot

Use Webhooks and Generators to build a self-escalating chatbot in Conversational Agents (Dialogflow CX). Application developers must create chatbots that can accurately offer information and recognize when to escalate a user’s issue to a human agent, as conversational AI becomes an increasingly important aspect of the user experience.

This blog article will demonstrate how to use Google Cloud’s generative AI products, including Conversational Agents (Dialogflow CX) and Vertex AI, to build a self-escalating chatbot.

The solution has a number of advantages:

  • Better user experience: Even for complicated queries, users get quick help and accurate information.
  • Reduced agent workload: Agent effort is decreased since agents are given succinct recaps of prior exchanges, which enables them to handle problems quickly.
  • Improved chatbot capabilities: By learning from escalated requests, the chatbot can get better at handling encounters in the future.
  • Enhanced security and scalability: Cloud Run Functions (CRF) offers a safe and scalable environment for executing the webhook function.

Build the knowledge base

Suppose it would like a chatbot to respond to inquiries on Indian tourism. First, it will develop it using Conversational Agents (Dialogflow CX) and Vertex AI Agent Builder.

Datastore without structure: To use Vertex AI to index an article on “Tourism in India” as an unstructured datastore. This enables the chatbot to instantly access and extract pertinent information from the article, giving thorough responses to user inquiries.

Conversational Agents (Dialogflow CX): To utilize Conversational Agents (Dialogflow CX) to create the conversational flow, which allows the chatbot to comprehend user intent and react accordingly.

Gauge user satisfaction

Asking the user if they are happy with the chatbot’s response is an essential part of the conversation flow that to include to guarantee user happiness. This is accomplished by employing “yes” and “no” chips that are defined as part of the custom payload, giving consumers an easy-to-understand method of expressing their opinions.

Escalate with generative AI

The chatbot starts the escalation procedure if the user clicks “no,” indicating discontent. This is where generative AI’s capability is useful.

Generators: In Conversational Agents (Dialogflow CX), it develop a generator called “Summarize_mail” that summarizes the discussion using a zero-shot prompt, which is a direct prompt without any examples. The body of an email is then created using this summary, giving the human agent context.

You are an English expert in summarizing the text in form of a very short mail.
Summarize the conversation and write it in form of a concise e-mail which will be forwarded to an agent as a ticket. The mail should be on point, properly formatted and written in formal tone with a polite closure. Keep the text as less as possible.
Also, specify the conversation messages below the summary which are present in the conversation. The conversation is as follows: $conversation
The feedback of the user about the issue is $last-user-utterance.

Model setup: To assist guarantee logical and instructive summaries, this generator makes use of the Gemini-1.5-flash model with a temperature of 0.3.

Trigger the email with Cloud Run Functions (CRF)

To link it Conversational Agents (Dialogflow CX) agent to a serverless function that is set up on Cloud Run Functions via a webhook in order to send the email. The logic for sending emails is handled by this function.

Configuring Cloud Run Functions (CRF): The following options are used while configuring the CRF:

  • Python 3.12 is the runtime.
  • Setting: Second Generation
  • Point of entry: handle_webhook
  • Type of trigger: HTTPS
  • Allotted memory: 256 MiB
  • Settings for ingress: Permit all traffic.
  • Requirements: functions-framework==3 (requirements.txt).

For Dialogflow CX Webhooks, are you unsure which CRF version to select? Here’s how to make a decision quickly:

  1. First Generation: Suitable for simple webhooks with less demanding performance needs, it is easier to set up and deploy.
  2. Second Generation: Better suited for intricate webhooks or high-traffic situations, it provides greater flexibility, control, and scalability.

Connect the pieces

To guarantee that the escalation procedure is initiated appropriately when necessary, provide the URL of it installed CRF as the webhook URL in Conversational Agents (Dialogflow CX).

Here’s how it all comes together

With a focus on the escalation process and the function of the CRF, this breakdown offers a thorough knowledge of the Conversational Agents (Dialogflow CX) flow architecture. Don’t forget to modify the email’s text, messages, and flow to fit your unique requirements and branding.

The name of the flow, such as “Customer Support Flow”

Pages: “Start Page” and “Escalate” are the two pages.

Start Page

Purpose: The goal is to greet the user and start a conversation while measuring their level of happiness.

Greeting entry fulfillment:

“Hello, name!” says the agent. Tell us how to may help you, please.

Datastore response entry fulfillment:

  • “Are you satisfied with the response?” asks the agent.
  • (This generates the “Yes” and “No” chips.) Custom payload

Routes:

Status: “Yes” chip was chosen

  • Transition: First page (Denotes that the discussion was successful.)
  • “Thank you!” says the agent. Do you need to assistance with anything else?

Situation: “No” chip was chosen

  • Transition: Page “Escalate”
  • “Sorry to hear that!” the agent says. (Recognizes user discontent.)

Escalate

Purpose: Providing the user with the choice to escalate to a human agent is the goal.

Fulfillment of entry:

  • “Would you like to escalate?” asks the agent.
  • (Identical “Yes” and “No” chips as the “Start Page”) Custom payload

Routes:

Situation: “No” chip was chosen

  • Change of Scene: “Start Page”
  • “Sure, Thank you!” the agent replies. (Permits the user to keep using the bot.)

Status: “Yes” chip was chosen

  • “Escalation Webhook” is the transition.
  • Webhook: Functions of Cloud Run (Starts the escalation procedure)

Goals:

It use the training terms “yes” and “no” to indicate the two intentions “confirm.yes” and “confirm.no.” This is equivalent to the user clicking on the “yes” and “no” chips or just writing the words or phrases that are comparable.

Cloud Run Functions (Escalation Webhook)

Trigger: When the “Escalate” page switches to the webhook, the HTTPS Eventarc trigger is triggered.

Usability:

  • Compile the history of the conversation: Using the $conversation in the generator prompt, which records the discussion between the agent and the user, excluding the user’s final utterance and the agent’s subsequent utterances, get and parse the whole conversation history from the Conversational Agents (Dialogflow CX) session.
  • Create a succinct synopsis of the discussion ($conversation), emphasizing any important user requests or problems.
  • Retrieve user data: Get the user’s email address (along with any other pertinent information) from your user database or the Conversational Agents (Dialogflow CX) session.
  • Write an email: Make an email using:
  1. Topic: (for instance, “Escalated Conversation from [User Email]”)
  2. Recipient: The email address of the support agent
  3. CC: The email address of the user

Body:

  • Details about the user (e.g., name, ID)
  • Synopsis of the conversation
  • If accessible, a link to the entire discussion in Conversational Agents (Dialogflow CX)

Send email: Send the email using the API provided by your email provider or an email sending library (such as sendgrid, mailgun, or smtp).

Optional return response: Notify Conversational Agents (Dialogflow CX) that the user’s request has been escalated by sending a response (e.g., “The mail is successfully sent!” or “Your request has been escalated”). An agent will be in touch with you soon.”

Chatbot testing and results

You may test the chatbot by clicking “Publish” and then “Try it now” after finishing the aforementioned steps.

A few examples of user journeys are as follows:

  • The user does not want to escalate further since they are dissatisfied with the response.
  • The user escalates as well since they are dissatisfied with the response. The right image below displays an example of triggered mail.
  • This method demonstrates how to integrate several Google Cloud services, such as Vertex AI, to create intelligent and intuitive chatbots.
  • This may anticipate even more creative solutions that improve client experiences as conversational AI develops further.
Drakshi
Drakshi
Since June 2023, Drakshi has been writing articles of Artificial Intelligence for govindhtech. She was a postgraduate in business administration. She was an enthusiast of Artificial Intelligence.
RELATED ARTICLES

Recent Posts

Popular Post

Govindhtech.com Would you like to receive notifications on latest updates? No Yes