Build an AI Chatbot using a Generative AI Model with Dialogflow Knowledge Base.

Introduction

The exploration focuses on examining the workings of Dialogflow CX, a tool that assists in human-like conversations, and the advanced Gemini Pro model, a highly intelligent AI. It focuses on demonstrating their combined impact in revolutionizing the development of conversational agents. It’s all about how these two join forces to transform how we create these interactive virtual assistants.

The weblog will underscore the pivotal role of agent generation in transforming user experiences and optimizing interactions. It will elucidate how the fusion of Dialogflow CX and the Gemini Pro model elevates the creation of conversational agents, making interactions more intuitive, seamless, and human-like.

Exploration of Dialogflow CX

The weblog will provide an in-depth understanding of Dialogflow CX, highlighting its pivotal role in crafting intelligent conversational agents. Readers will gain insights into its features, functionalities, and its unique position in the realm of conversational AI platforms.

Let’s begin by creating a Dialogflow agent with a knowledge base.

1. Google signup

To start using Dialogflow you need to have a Google Account. If you already use Gmail, you can log in using that account. Or you can create a new Google account.

2. Create a Project

To start with a new chatbot development in Dialogflow, we need to create a project. And make sure that Dialogflow API is enabled from your Google Cloud Console.

If your API is not enabled refer to this https://support.google.com/googleapi/answer/6158841?hl=en document. Enable Dialogflow API.

3. Create an Agent

To start with a new chatbot development in Dialogflow, we need to create an agent.

  • Click on which type of bot you want to create, here we select ‘Build Your Own’ to create our custom bot.

Provide a name for your agent and select the default timezone. Choose the default language as per your preference.

Click on ‘Create’.

Exploration of Gemini Pro Model

The Gemini Pro model is a powerful generative AI tool developed by Google DeepMind. It excels at several tasks, making it a versatile option for various applications, including Knowledge Base Dialogflow.

Integrating Gemini Pro into platforms like Dialogflow potentially enhances the chatbot’s ability to understand and respond to user queries more effectively, particularly within a knowledge base setup.

It might incorporate multi-modal capabilities, allowing it to process and generate responses based not only on text but also on other modalities like images or structured data, though the extent of this integration might vary.

With Gemini Pro, now developers can build “agents” that can process and act on information.

What is Bucket?

Cloud Storage Buckets serve as fundamental storage units for your data. All information stored in Cloud Storage must reside within a bucket. These buckets enable data organization and access control. However, unlike directories or folders, they do not support nesting of other buckets within them.

  • You can create an unlimited number of buckets within a project or location.
  • Upon creating a bucket, you assign it a globally unique name and designate a geographic location for storing both the bucket and its contents.
  • The pricing structure, covering costs for data storage, processing, and outbound data transfer, is influenced by factors like the bucket’s location and the storage classes of its objects. For detailed information, refer to cloud Storage pricing.
  • Identity and Access Management (IAM) is used to control access to individual buckets.

When creating the bucket, you have to remember these things.

  • Ensure you’ve chosen the project associated with the agent you’re using.
  • Use Standard Storage class.
  • Ensure the bucket location aligns with your agent’s designated location.

4. Create buckets

To create a new bucket, go to the Cloud Storage Buckets page and click on the ‘Create’ button.

Enter a globally unique bucket name, choose from the available options for your buckets, and click on ‘Create’.

You can create a folder, upload files, upload a folder, and transfer data to and from here. Additionally, you can directly upload files by clicking on ‘Upload Files’.

What is a Data stores?

Data store agents utilize data stores to locate answers to user queries within your data. These stores comprise various websites and documents, all referencing your data.

When a user poses a question, the agent seeks an answer within the provided content, condensing the information into a clear response. It also offers relevant source links, allowing users to explore further. The agent can furnish a maximum of five concise answer snippets per question.

5. Create a data store

To create a new data store, navigate to the ‘Data Stores’ option in the left-hand menu under the ‘Manage’ tab.

Click on ‘NEW DATA STORE’.

Select a Data Source for your data store, and which types of data you want to store in your data store.

Various sources are available for supplying your data, like Website URLs, BigQuery, and Cloud Storage, data can be structured or unstructured, and it can be with or without metadata.

Import data from GCS

Click on the ‘browser’ to view the bucket data, which includes files and folders. Select the files or folders you want to import, and also specify the types of data you wish to import.

Click on ‘Continue’.

Give a name to your data store and click on ‘Create’.

What is a Data store agent?

Data store agents, a unique variant of Dialogflow agents, offer LLM-generated agent responses derived from your website content and uploaded data.

To create a data store agent, you have to supply data stores during its creation.

Data store agents feature specialized state handlers called data store handlers, allowing your agent to engage end-users in conversations about the content.

6. Create a data store agent

Go to the Search and Conversation page or click on Create Vertex AI Search and Conversation app.

Click on ‘NEW APP’.

Select the type of application you want to create, for example, we have chosen the Chat option.

Fill in all the required details, and then click on ‘Continue’.

Link a data store to your agent by performing one of the following actions:

  1. Select the data store if you already created it.
  2. Otherwise, Click on CREATE NEW DATA STORE.

Click on ‘Create’.

A Data Store agent is created.

7. Verify your agent’s performance by conducting tests

The Dialogflow CX simulator is available for testing your agent.

Select your project name and agent name, then click on ‘Test Agent’.

We display the agent’s response to the user’s inquiries here.

Improve the agent’s generative responses

Click on ‘Agent Settings’, and open the Agent Settings page.

Navigate to the ‘Generative AI’ sub-tab, which offers several options to enhance the quality of an agent’s generative responses.

Further down the page, you’ll find an option related to ‘Grounding confidence’.

Grounding confidence

We measure the confidence level of responses created from your connected data store, ensuring the information aligns with the data. You can adjust the allowed response types by setting the minimum confidence level. Responses falling below this threshold won’t be displayed.

You have the choice of selecting from five confidence levels:

  • Very low
  • Low
  • Medium
  • High
  • Very high

Click on the dropdown box it displays the various options for confidence level.

Select any one option.

Data store prompt

You can improve the quality of the responses generated from the data store content by including additional information about the agent.

Fill in all required details.

Once you’ve completed this section, either partially or entirely, you’ll find, on the right side under “Your prompt,” a brief paragraph generated from these settings. This paragraph will be used in generating answers.

Here, is an example of a prompt:

Your name is Indian Road Safety, and you are a helpful and polite Road Safety Officer at Indian Road Safety Agency, Promoting road safety nationwide. Your task is to assist humans in providing information for OFFENCES, PENALTIES, AND PROCEDURE in India.

Select the generative model

You can choose the generative model that a data store agent uses for the summarization of generative requests.

8. Add or edit data store handlers for an existing agent

Apply flows or pages to the data store handlers.

Select the flow associated with the data store handler. Commonly it is the default start flow.

Select the page associated with the data store handler. Commonly it is the start page.

Click ‘Add state handler’, then select Data Store and click on ‘Apply’.

If you want to create a new data store, then click on the search and conversation app.

Click on the ‘+’ symbol to add the data store.

Select the data store that you have already created and click on Save.

Agent responses

In the section for Agent responses, you can create custom replies that make use of generative answers as references.

Use $request.knowledge.questions[0] in the ‘Agent says’ section for generative answers.

Outcomes

We tested several questions related to Road Rules and Regulations for India using the Gemini Pro Model.

We’ve included some of the tested questions here,

Q1: If I drive a vehicle without a license then what happens

Ans: If you drive a vehicle without a license, you may be fined Rs. 5000.

Q2: Can I drive a vehicle without a permit

Ans: No, you cannot drive a vehicle without a permit.

Q3: vehicle permit is compulsory?

Ans: Yes, a permit is required to use a motor vehicle as a transport vehicle in any public place, whether or not it is carrying passengers or goods. The permit must be granted or countersigned by a Regional or State Transport Authority or any prescribed authority.

Q4: Unauthorized user drive a vehicle then any fine for that?

Ans: Yes, there is a fine for unauthorized users driving a vehicle. The fine is 5000 rupees.

We’ve additionally included a screenshot containing these same questions.

Follow the steps above to add or edit data store handlers for an existing agent.

Conclusion

By harnessing the combined power of Dialogflow CX’s conversational management and Gemini Pro’s generative AI capabilities, we’re entering a new era of conversational AI where building chatbots becomes more intuitive and efficient, shifting from complex coding to natural language prompts and datastore. Now the Conversations become seamless, human-like, and contextually aware, leading to more engaging and satisfying interactions.

Originally published at Build An AI Chatbot Using A Generative AI Model With Dialogflow Knowledge Base on February 2, 2024.


Build an AI Chatbot using a Generative AI Model with Dialogflow Knowledge Base. was originally published in Chatbots Life on Medium, where people are continuing the conversation by highlighting and responding to this story.


Posted

in

by

Tags: