Create a Generative Chat App with Vertex AI Conversation

1. Overview

What you'll build

In this codelab, you'll use Data Store Agent functionality in Vertex AI Conversation to build, configure, and deploy a virtual agent that can assist customers who have questions about products and devices in the Google Store, including phones, watches, laptops, smart home devices, and other consumer devices.

What is a Data Store Agent?

A Data Store Agent is a feature within Vertex AI Conversation that is built on top of functionality in Dialogflow CX.

With a Data Store Agent, you can provide a website URL, structured data, or unstructured data, then the Data Store Agent parses your content and creates a virtual agent that is powered by data stores and large language models. Your customers and end users can then have conversations with the agent and ask questions about the content. Refer to the Data Store Agent documentation for more information.

People searching for information on a laptop

What you'll learn

  • How to create a Data Store Agent
  • How to add unstructured data to your agent's data store
  • How to enable voice and chat experiences for your agent
  • How to test your agent and simulate customer questions
  • How to view conversation history and analytics for your agent

What you'll need

  • A Google Cloud Project
  • A browser such as Chrome

2. Enable APIs

Before you can start with a Data Store Agent in Vertex AI Conversation, you need to enable the Dialogflow as well as the Vertex AI Search and Conversation APIs.

To enable the Dialogflow API, follow these steps:

  1. In your browser, navigate to the Dialogflow API Service Details page.
  2. Click the Enable button to enable the Dialogflow API in your Google Cloud project.

To enable the Vertex AI Search and Conversation API, follow these steps:

  1. In the Google Cloud console, navigate to the Vertex AI Search and Conversation console.
  2. Read and agree to the Terms of Service, then click Continue and activate the API.

3. Create a new chat app

Now, you'll create a new chat app for your virtual agent and configure it with a data source. The purpose of the agent that you'll build is to assist customers who have questions about products in the Google Store.

You'll use the Vertex AI Conversation console and Dialogflow CX console to perform the remaining steps in this codelab to create, configure, and deploy a virtual agent that can handle questions and answers using a Data Store Agent.

  1. To create a new chat app in Vertex AI Conversation, you can either:
    1. Navigate to the Vertex AI Conversation console, then click +New app near the top of the console.
    2. Navigate to the Dialogflow CX console, click +Create new agent then selecting the Auto-generate option, then you'll be redirected to the following step in the Vertex AI Conversation console.
  2. From the Vertex AI Conversation console, select Chat as the type of app that you want to create.
  3. Input a Company name of Google Store. This parameter is used to define the company that your agent represents and the scope of your agent.
  4. Specify an Agent name of Google Store.
  5. Click Continue.
  6. Click Create new data store.
  7. Select Cloud Storage as the data source for your data store.
  8. Specify the following Google Cloud Storage folder that contains sample data for this codelab, and note that the gs:// prefix is not required:
    cloud-samples-data/dialogflow-cx/google-store
    
  9. Select Unstructured documents as the type of data you are importing.
  10. Click Continue.
  11. Specify a Data store name of Google Store.
  12. Click Create to create the data store.
  13. In the list of data stores, select the newly created Google Store.
  14. Click Create to create your chat app.

Congratulations! You are finished building your knowledge-powered chat app that's ready to help your customers, so take a moment to celebrate!

But there's still more work to do to make the bot accessible to your users. In the next section, you'll test your virtual agent and see how good it is at answering user questions about various products in the Google Store.

4. Test your virtual agent

Testing is an important part of working with conversational agents to find bugs, identify limitations, and simulate a customer experience. You can start an interactive session with your chatbot to see how it responds to various questions that a customer might ask.

  1. From the Vertex AI Conversation console, click the name of your chat app, which will redirect you to the Dialogflow CX console for further testing and customization.
  2. In the Dialogflow CX console and from within your agent, click Test Agent to open the Simulator.Test agent in Dialogflow CX
  3. Type a greeting to your agent such as Hello.
  4. Ask the agent some questions about various products such as:
    • How long does the battery in the Pixel 7 Pro last?
    • Is the Pixel Watch water resistant?
    • Can I display my Google Photos on a Nest Hub?
    • Ask other questions about doorbells, thermostats, smart lighting, or other devices in the Google Store.

Testing your virtual agent

Great work! Notice that your virtual agent knows quite a bit about different products in the Google Store since it ingested information from the root domain that you specified earlier. Refer to the documentation for the agent simulator to learn more about testing your agent.

5. Enable voice calls

Now that you've tested your agent and are happy with its current level of functionality, you can add a phone gateway to your bot, which will make use of the Speech-to-Text and Text-to-Speech capabilities in Google Cloud.

  1. In the Dialogflow CX console and from within your agent, click the Manage tab in the sidebar, then click Integrations.
  2. Click Manage under the CX Phone Gateway section at the top of the Integrations page.Integrations - CX Phone Gateway
  3. On the Phone numbers page, click Create New to start the process of creating a new phone number for your virtual agent.
  4. Select a country code and click Request to continue to the next step.
  5. Select one of the phone numbers that appears, input a display name, then click Save.
  6. Call your agent and ask it some questions!
    • Do the Pixel 7 Pro and Pixel 7 both have face unlock?
    • What coverage does Preferred Care provide for a Pixelbook Go laptop?
    • Do the Pixel Buds Pro have active noise cancellation?
    • Ask other questions about doorbells, thermostats, smart lighting, or other devices in the Google Store.

Congratulations, you gave your virtual agent its own phone number and voice! For more information on other available voice and telephony integrations, refer to the documentation for Dialogflow CX Integrations.

Next, you'll integrate a chat messenger for your virtual agent into an external website.

6. Enable chat widget

Now that your bot has a phone gateway for voice interactions, let's embed a chat widget on a website so customers can chat with it in addition to making a phone call to speak with it.

  1. In the Dialogflow CX console and from within your agent, click the Manage tab in the sidebar, then click Integrations.
  2. Click Connect under Dialogflow Messenger.
  3. Click Enable in the dialog, then copy the HTML code for the messaging integration.
  4. Open an online code editor such as CodePen or JSFiddle and paste your Dialogflow Messenger HTML code.
  5. Test and chat with your virtual agent! Here are some sample questions to ask:
    • Do the Pixel 7 Pro and Pixel 7 both have face unlock?
    • How does Preferred Care relate to a Pixelbook Go laptop?
    • Do the Pixel Buds Pro have noise cancellation?
    • Ask other questions about doorbells, thermostats, smart lighting, or other devices in the Google Store.

Now your virtual agent can now handle questions and answers from your customers via chat or voice, whichever they prefer! For more information on other available chat integrations, refer to the documentation for Dialogflow CX Integrations.

Chat integration with Dialogflow Messenger

7. Conversation analytics

When testing your virtual agent, if you find that your bot's answers do not meet your expectations, you can always add more URLs to the data store to improve how your bot handles questions and answers.

Other than testing many different paths that customers might take, how else can you determine where the problems and friction points are in your virtual agent? Conversation history and analytics can help!

  1. In the Dialogflow CX console and from within your agent, click Agent settings in the menu.Agent settings in Dialogflow CX
  2. Under Logging settings, select Enable Conversation History.Enable Conversation History in agent settings
  3. Have a conversation with your bot via the agent simulator, voice integration, or chat integration, and ask it some questions.
  4. After you end the conversation with your agent, in the Dialogflow CX console and from within your agent, click the Manage tab in the sidebar, then click Conversation history.Conversation history in Dialogflow CX
  5. Click one of the recent conversations, then review the conversation and note the duration of the conversation, the responses that were given by the agent, and which intents were matched along the way.Conversation detail in Dialogflow CX
  6. In the Dialogflow CX console and from within your agent, click the Manage tab in the sidebar, then click Analytics. As customers interact with your agent, this page will show a summary of various statistics related to agent requests and responses.

Great! Now you know how to look into specific conversations in more detail and review other metrics related to your agent responses and customer interactions. Refer to the documentation for conversation history and conversation analytics for more information on evaluating performance and viewing metrics for your agent.

This data helps you assess how your agent is being used in production and can be used to determine which websites and documents you might want to add to your knowledge base to improve your agent and customer experience.

8. Congratulations

Using Vertex AI Conversation and Dialogflow CX, you've successfully created a Data Store Agent, added data sources, and deployed a voice-enabled and chat-enabled agent to help your customers!

Your virtual agent can answer hundreds of different questions about products in the Google Store, and you didn't have to go through the manual process of creating a large number of intents, training phrases, response messages, etc.

Feel free to try out other data types in your data stores and explore the other functionality available related to Vertex AI Conversation and Dialogflow CX.

Happy support agent

Clean Up

You can perform the following cleanup to avoid incurring charges to your Google Cloud account for the resources used in this codelab:

  • To avoid unnecessary Google Cloud charges, use the Google Cloud console to delete your project if you do not need it.
  • If you used an existing Google Cloud project, delete the resources you created to avoid incurring charges to your account. For more information, refer to the steps to Delete an app.
  • If you want to disable the APIs for Vertex AI Conversation and Dialogflow, navigate to the Discovery Engine API Service Details page and click Disable API and confirm, and navigate to the Dialogflow API Service Details page and click Disable API and confirm.

Learn More

Continue learning about conversational AI and generative AI with these guides and resources:

License

This work is licensed under a Creative Commons Attribution 2.0 Generic License.