Real-Time Domain-Specific RAG Chatbot
A real-time chatbot that uses Google Search restricted to your own domain, retrieves relevant web content, and leverages OpenAI LLM to answer user queries with up-to-date information. Ideal for providing accurate, domain-specific responses in customer support or information portals.


How the AI Flow works
User Query Input
Captures user questions via chat input or pre-defined buttons.Query Expansion
Paraphrases and expands the user query to improve retrieval accuracy.Domain-Specific Google Search
Performs a Google Search limited to the specified domain using the expanded queries.Web Content Retrieval
Fetches the content from the top relevant URLs returned by the search.LLM Response Generation
Uses OpenAI LLM to generate a final, context-enriched answer displayed to the user.Prompts used in this flow
Below is a complete list of all prompts used in this flow to achieve its functionality. Prompts are the instructions given to the AI model to generate responses or perform actions. They guide the AI in understanding user intent and generating relevant outputs.
Components used in this flow
Below is a complete list of all components used in this flow to achieve its functionality. Components are the building blocks of every AI Flow. They allow you to create complex interactions and automate tasks by connecting various functionalities. Each component serves a specific purpose, such as handling user input, processing data, or integrating with external services.
Flow description
Purpose and benefits
Overview
This workflow implements a simple Retrieval-Augmented Generation (RAG) chatbot that leverages real-time Google Search to retrieve up-to-date information from the internet—specifically, it can be customized to restrict all searches to a particular domain. The main goal is to create a chatbot that can answer user queries using the most relevant and recent content found online, making it highly valuable for scenarios where static knowledge bases are insufficient.
Key Components and Flow
The workflow is composed of several modular blocks, each representing a specific capability. Below is a breakdown of the workflow’s structure and functionality:
Component | Role |
---|---|
Chat Input | Receives user queries and chat messages. |
Chat History | Maintains conversation history for context-aware responses. |
Query Expansion | Paraphrases user input into multiple alternative queries to improve search coverage. |
Google Search | Executes searches on Google, restricted by a customizable domain prefix. |
URL Retriever | Extracts content from the URLs returned by Google Search. |
Prompt Template | Structures context, user input, and history for the language model. |
OpenAI LLM | Generates responses using a language model (e.g., GPT-3/4). |
Generator | Invokes the LLM with the prompt and context to produce the answer. |
Chat Output | Displays chatbot responses to the user. |
Button Widgets | Provides quick example queries for users to try with a single click. |
Chat Opened Trigger | Initializes the conversation and populates quick-start buttons. |
How the Workflow Operates
When a user opens the chat, the Chat Opened Trigger activates. This initializes the chat interface and presents several Button Widgets with example queries (e.g., “what dinosaur has 500 teeth?”). When a user clicks a button or enters a custom message via Chat Input, the workflow proceeds as follows:
Query Expansion: The user’s input is paraphrased into multiple versions to maximize the likelihood of retrieving relevant search results.
Google Search: The expanded queries are sent to Google Search. By default, the search is limited to a specific domain (set by the
query_prefix
field, e.g.,site: www.YOURDOMAIN.com
), allowing you to focus the chatbot’s knowledge on your own website or any trusted source.URL Retriever: The workflow retrieves the content of the top search results (URLs) as full documents.
Prompt Assembly: The retrieved content, user input, and chat history are combined using the Prompt Template component to provide rich context for the answer.
Language Model Generation: The prompt is sent to the OpenAI LLM, which generates a coherent and contextually relevant response.
Response Output: The generated answer is displayed to the user via the Chat Output.
Example Use Case Flow
- User opens chat: Welcome message and three example question buttons appear.
- User clicks “when is mother’s day 2024?”: The question is immediately shown in the chat output (for instant feedback).
- The workflow runs the query through expansion, search, retrieval, prompt assembly, and LLM generation, then displays the answer.
Why This Workflow is Useful
- Real-time Knowledge: The chatbot can answer questions using the latest information available on the internet or your chosen domain.
- Domain Restriction: By customizing the
query_prefix
, you can ensure the chatbot sources information only from your trusted website or knowledge base, improving the reliability of answers. - Context Awareness: By including chat history and retrieved content in the prompt, responses can be tailored and contextually relevant for multi-turn conversations.
- Scalability and Automation: The modular design allows the workflow to be easily extended or adapted for various domains, supporting large-scale deployment across different topics or websites.
- User Experience: Quick-start buttons and instant feedback make the chatbot approachable for end-users.
Workflow Summary Table
Step | Description |
---|---|
User Input | User types a question or clicks a quick-start button |
Query Expansion | Input is paraphrased for broader search coverage |
Google Search | Searches are performed on Google, restricted to a given domain |
URL Content Retrieval | Top search result contents are fetched |
Prompt Construction | User input, search results, and chat history are compiled into a prompt |
LLM Generation | OpenAI LLM generates a response using the full context |
Output | Response is shown to the user |
Customization
- To focus the chatbot on your own domain, modify the
query_prefix
field in the Google Search component (e.g.,site: www.YOURDOMAIN.com
). - Add or change example queries using the Button Widget components for a more tailored user experience.
Ideal Use Cases
- Customer support bots that always give answers based on your up-to-date documentation or web content.
- Internal knowledge assistants limited to your company’s intranet or support portal.
- Any chatbot that must always cite or rely on external, authoritative sources (e.g., for compliance or accuracy).
By automating the search, retrieval, and answer generation process, this workflow saves manual research time and ensures users always get the most current and relevant information available.
Let us build your own AI Team
We help companies like yours to develop smart chatbots, MCP Servers, AI tools or other types of AI automation to replace human in repetitive tasks in your organization.