How to build a conversational AI experience using generative AI to improve employee productivity
Generative AI Solution Architect, Google Could
A major source of frustration for any large organization, whether non-profit, public, or private, is the difficulty that individuals and teams within the organization have in locating relevant information both internally (on intranets) and externally (on the web). Employees can waste a significant amount of time trying to zero in on the right intranet or web source of information for various daily work related questions; or they might struggle to find the right internal expert to assist with the topic they seek answers about.
Google Cloud’s generative AI capabilities now enable organizations to address this pain point by leveraging Google’s best-in-class advanced conversational and search capabilities. Using Google Cloud generative AI features in Dialogflow, you can create a lifelike conversational AI agent that empowers employees to retrieve the most relevant information from internal or external knowledge bases. Generative AI features in Dialogflow leverages Large Language Models (LLMs) to power the natural-language interaction with users, and Google enterprise search to ground in the answers in the context of the knowledge bases. The knowledge base could consist of both structured and unstructured data.
In the following sections we provide an example on how to build a chat experience that handles HR benefits questions from both external websites and an internal FAQ knowledge base. Additionally, because the user may need to consult with a human HR representative for a specific situation, the Dialogflow virtual agent is able to find the right HR representative based on the conversation topic, and follow up with making an appointment by calling the calendar API. The core components of this example include:
- Generative AI Agent: uses generative capabilities. An agent can be used to create a lifelike chat or voice experience in minutes, for which the conversational answers would be grounded in the user-provided knowledge base.
- Playbooks: a Playbook is a generative agent designer for building flow and tasks to be carried out by the virtual agent. Playbooks can be designed and created simply based on instructions written in natural language.
- A webhook: a service that hosts business logic or calls other services, API, etc.
- Intents and routes: An intent categorizes an end-user intention for one conversation turn. Routes are connections among flows and conversations. We use an intent to route a conversation to the right flow.
Build a chatbot using gen AI to improve employee productivity
Getting started takes a few simple steps. First go to the Vertex AI Conversation console to build your data store/knowledge base. Then, you can start to create a transactional agent with multi-turn conversation and call external APIs using Dialogflow. Before diving into the steps, let’s look at the use case that led to creating a conversational AI experience using generative AI.
Miranda recently joined a company with 500 employees. She’s spending countless hours trying to get up to speed on understanding benefits, compensation, performance reviews, and different aspects of the organization. It would be great if Miranda had, within her company’s web portal, a lifelike virtual agent to allow employees to find the right information and right people, quickly. This use case is applicable to any industry and organization. A user journey for Miranda would go as follows:
As a new employee, Miranda wants to know:
- How to enroll in benefits as a new hire. For example what information she needs to provide and what internal tools she can use.
- What are the various benefit options available to her?
- How to add her dependents to a benefit, such as the dental plan.
- What steps she needs to update her benefits and enrollment.
Miranda also wants to consult with a HR representative in person to understand how her compensation was modeled and how her performance will impact future compensation.
Step 1: Create agent data store (knowledge base)
1. In the Vertex AI Conversation console, create a data store using data sources such as public websites, unstructured data, or structured data.
2. Go to Cloud Storage, create a bucket with name “demo-better-employee-search” and select “continue” until the final step, “create” the bucket.
3. Upload your document to the Cloud Storage bucket. We support:
- Text/HTML for public domain and website
- HTML, PDF and CSV for private document and FAQ document
4. Switch back to Vertex AI Conversation console and add data to your data store. There are three options to upload data:
- Cloud Storage (without metadata): store your document in a Cloud Storage Bucket
- Cloud Storage (with metadata): store JSONs in a Cloud Storage bucket with links to your documents and metadata
- BigQuery (with metadata): store a table in BigQuery with links to your document and metadata
- API : Import data by calling API
Step 2: Create a generative AI agent to handle frequently asked questions using Data Store
The Generative AI Agent is a chat experience that can answer questions based on the organization’s knowledge base. After creating a data store in the previous step, you will be navigated to the Dialogflow CX console. Click “Test Agent'' to try out the virtual agent.
Step 3. Create a Playbook to map HR topics and HR representatives
Conversations can be categorized by generative AI-powered Playbooks. A Playbook can be defined by topics and the associated conversational path. For example, a pizza ordering agent might have playbooks or flows such as pizza order, customer information, make a payment, etc. In this virtual agent design, we use instructions from a Playbook to map HR topics with HR representatives.
Unlike a standard flow, which can be built by intents, training phrases, etc, Playbooks can be created based on instructions written in natural language to define tasks for virtual agents.
In this step, we first create parameters before creating instructions. Parameters are used to capture and reference values that have been supplied by the end-user during a session. Each parameter has a name and entity type.
1. Create three parameters for user data, hr_topics, hr_representative, and appointment as input parameters. Input parameters are collected and made available to the flow.
2. Create output parameter to collect “@sys.date” to obtain appointment availability during conversation. Input parameters are expected to be collected from the Playbook.
3. Setup instructions to describe what the flow does. Then identify steps to map $hr_topics and $hr_representative*.
*This feature is currently in GA via allowlist
Step 4. Route flows
To design the virtual agent, we identify intents to build a storyline, which is similar to creating an outline when writing a story. In the storyline, we build:
- A deterministic flow using FAQ pairs, website, or private documentation. In this tutorial we use the deterministic flow to answer HR/benefit related questions, such as “what leave options are available for me as a US based employee?” (see step 2)
- Transactional flows to answer users’ questions or complete certain transactions (see step 3). In the tutorial we use the transactional flows to help Miranda to find the right HR representative and schedule a session.
- Intents and/or playbooks instructions to route conversations.
In the following section, we will learn how to build intents to route conversations.
An intent categorizes the end user’s intention during the conversation. Intents can be categorized as head intents and supplemental intents. Head intents identify users’ primary purpose for interacting with an agent, while a supplemental intent identifies a user’s subsequent questions. For example, in a pizza ordering virtual agent design, “order.pizza” can be a head intent, and “confirm.order” is a supplemental intent relating to the head intent. After identifying intents, you can add training phrases to trigger the intent.
In this tutorial, we create a head intent “redirect.schedule.appointment” to route conversations from Default Start flow to MapRepresentative flow. This can be triggered by utterances such as “ I want to talk to a HR representative.” We also build “confirmation” intents as supplemental to address users' utterances such as “the schedule works for me.”
Step 5. Combine predictive and generative flows to complete the conversation
Conversation dialogue includes multiple conversation topics. With Dialogflow, you can combine predictive flows with specific, prescriptive intents with generative flows created by Playbooks. In the example, we build the following structure:
- Default start flow is to host the data store/knowledge base, and route intents to the appropriate flows or Playbooks (see step 3 and step 5).
- Build MapRepresentative Playbook to find the right HR representative based on the user topics (see above step 4).
- Create FindRepresentative flow to route conversations for finding out the right representative and call the calendar API for an appointment (see step 6 below on how to create webhook to call the calendar API).
- The ConfirmAppointment flow ends the conversation gracefully. This is also a Playbook.
Step 6. Create a webhook to call the calendar API
In this step the virtual agent will check the HR representative’s availability, and integrate with the calendar API via webhook. This can be achieved by deploying cloud functions.
In Cloud Functions:
1) Enter your code to call calendar API in index.js
2) Provide package.json
3) Deploy the cloud functions. Please find sample code in github here
4) Configure a webhook in Dialogflow
It’s not trivial to design a virtual agent. In order to build robust conversation experience, some best practices include:
- Understand data and hierarchy of the conversation to design flows and head intents before any technical design. Determining which flows, or parts of flows, require intent-driven designs due to control, cost, security, or other reasons, and which can be addressed with Generative AI Agent or Playbooks.
- Flows are major topics. Intents are the user's intention, which is used to achieve the happy path of the major topics. Note that restricting the head intents to one or two within one flow can avoid complexity.
- Build reusable supplemental intents. Where possible, try to reuse intents across different flows. For example, supplemental intent “confirmation.yes” means that as you brainstorm ways of saying “yes.” “you bet,” “you got it captain,” you only have to use this one intent across different flows, as opposed to multiple.
- Use Default Negative Intent to remove any utterances that were originally out of scope. For example, in a pizza ordering flow, “I am going to cook chicken for dinner” is an out of scope utterance. Such utterances can be included in the Default Negative Intent.
In the example, we demonstrated how to create a virtual agent powered by generative AI that can answer frequently asked questions based on the organization’s internal and external knowledge base. In addition, when the user wants to consult with a human agent or HR representative, we use a “mix-and-match” approach of intent plus generative flows, including creating agents using natural language. We then added webhooks and API callsI to check calendar availability and schedule a meeting for the user.