Written by Stéphane Giron, Head of Customer Success and Support, Google Developer Expert and absolute FAN of Google Apps Script!
Introduction
Making data and information openly accessible is a major challenge for businesses. However, defining an optimised solution to achieve it can be challenging. In this article, there’s no secret recipe for achieving this, but we will share the latest implementation we carried out at Devoteam G Cloud using Vertex AI Search.
Starting point
All employees have HR-related questions, and answering them could be extremely time-consuming for HR teams. Therefore, providing all employees with a Chatbot that will answer the most common questions was something worth looking into.
Finding data with Vertex AI Search
At Devoteam G Cloud, Google Drive and Shared Drives are used to manage information and documentation. Although this method offers extensive storage space and advanced search capabilities, finding specific data can be laborious.
Indeed, even when the required document is located, sometimes it is still necessary to continue searching in the document to access the exact information requested. We will attempt to extend search capabilities with Vertex AI Search to provide generative AI responses to information retrieval.
Finding the right data will probably be the most complex part of the project. There is no possibility of entering all the available data into Vertex AI Search and expecting to get correct and accurate answers to your questions. You have to filter the files in order to maintain the consistency of the source information used by the application. No structured data is required; we used around 100 PDF documents. In Vertex AI, we call this type of document “unstructured documents”.
- As with Google Search, we suggest that you avoid mixing different types of information. It is preferable to have a pdf for each product rather than one with all the products.
- The file should not exceed 100MB.
- During testing, for multilingual bots, it is recommended to have one per language. This may no longer be the case in the future.
- The system can get lost in large files, which is why it’s better to separate certain files.
Manage your data
With Vertex AI Search, you can easily import files from Cloud Storage, all you have to do is upload them to the right location. The following explains how to manage files in Google Cloud Storage:
- Importing to Vertex AI is not effective for sub-folders, so please don’t create a complex hierarchy.
- You can combine all the files in a single folder, personally I opted to isolate the content by creating a few main folders. This makes it easier to search and update.
- It’s easy to import and update data from Cloud Storage, meaning you can start with partial data.
Create your Vertex AI Search application
The application can be created directly. The Data Store doesn’t need to be created beforehand; it’s just one step in the creation process.
Click on the creation page and select “Search”.
Please follow the instructions, and at the Data Store stage, you’ll need to create one using your Cloud Storage folder:
I won’t detail all the steps as it’s very simple to achieve.
Integrate Vertex AI Search in Google Chat
To create your first Google Chatbot with Apps Script, please refer to this Google Chat guide.
In this application, we’ll use Vertex AI Search’s multiturn functionality, allowing users to interact with the robot more intuitively. Users will be able to refine answers by asking several questions, and the robot will continue to answer based on previous questions and the answers provided. This Vertex AI Search guide explains it all.
Instead of covering all the development aspects, we’re concentrating on the Vertex AI Search part of Google Apps Script.
Start a conversation, and get a “Conversation ID
First, you need to create a “conversation ID” to access the multiturn functionality.
In this code, we’re going to create a user ID based on email, you can use any other method to generate this ID.
To initiate the process, you’ll need the Project ID and the Data Store ID. In this example code, the region is defined as “Global”. However, you can select the “Europe” region when creating the application, and then you will need to adapt the url to this region. For authentication, we use ScriptApp.getOAuthToken(), signifying that the logged-in user must have access to the Vertex AI Search application in the GCP project.
Send your first message
CONVERSATION_ID contains all the data regarding the project, etc… it is not necessary to specify it again in the url.
This function takes the user’s email and the question as input.
Keep the conversation going
To continue the conversation, the code is exactly the same as above, you just need to use the same CONVERSATION_ID to pursue the chat with the bot on the same topic.
Basically, this means that you need to keep track of the conversation ID between each message. There are several ways to do this on Google Apps Script, and it depends on your code.
Result
The following conversation contains a second answer that completes the first. The second question is just a natural question with no additional or repeated context:
- Q1: Does Devoteam G Cloud provide meal vouchers?
- Q2 : Who is the supplier?
As you can see, we are also displaying the source used to provide context for the answer. LLMs work very well, but you should always be careful about the answers you give – the source is a good indicator of the answer.
Empowering Employee Self-Service with Vertex AI Search Chatbots
In this article I have demonstrated how Vertex AI Search and Google Apps Script can be combined to create a functional chatbot within Google Chat. By leveraging Vertex AI Search’s ability to process unstructured data, the described approach allows organizations to make internal information more readily accessible to employees. This method offers a promising approach for businesses seeking to improve internal knowledge accessibility and streamline information retrieval for employees.
Want to build a chatbot that suits your needs? Contact our experts today and get started!