
Section 4 — Hands-On Example: Enterprise Chatbot
Let’s design an enterprise chatbot that answers HR-related questions (leave policy, benefits, etc.) using Gemini + Vertex AI Search + Dialogflow CX.
Step 1 — Ingest Data into Vertex AI Search
Suppose we have HR policy PDFs. We first upload them to Cloud Storage.
gsutil cp hr_policies/*.pdf gs://my-enterprise-bucket/hr-policies/
Then, create a Vertex AI Search data store:
gcloud discovery-engine data-stores create hr-datastore \
--location=global \
--display-name="HR Policies Store" \
--project=my-gcp-project
Step 2 — Connect Gemini with RAG
Now, use Python SDK to query Gemini with grounding:
from google.cloud import discoveryengine_v1 as discoveryengine
from vertexai.preview.language_models import TextGenerationModel# Query enterprise data
def search_enterprise_docs(query: str):
client = discoveryengine.SearchServiceClient()
request = discoveryengine.SearchRequest(
serving_config="projects/my-gcp-project/locations/global/collections/default_collection/dataStores/hr-datastore/servingConfigs/default_serving_config",
query=query,
)
response = client.search(request)
return [doc.document for doc in response]
# Generate grounded response
def generate_answer(query: str):
docs = search_enterprise_docs(query)
context = " ".join([d.content.text for d in docs[:3]])
model = TextGenerationModel.from_pretrained("gemini-pro")
response = model.predict(
prompt=f"Use the following HR documents to answer:\n{context}\n\nQuestion: {query}"
)
return response.text
print(generate_answer("What is the maternity leave policy?"))
Step 3 — Add Conversational Interface with Dialogflow CX
- Create a Dialogflow CX agent → integrate with Vertex AI Search pipeline.
- Use intents for FAQs + fallback handler that calls the Gemini RAG function.
This allows employees to chat with HR policies in natural language, with accurate, grounded responses.
Source Credit: https://medium.com/google-cloud/generative-ai-on-google-cloud-part-4-architecting-real-world-applications-c3c5cb918f03?source=rss—-e52cf94d98af—4