The Problem

Many AI chatbots rely only on pre-trained knowledge and cannot access real-time information from the internet. Because of this limitation, users cannot retrieve the latest news, updates, or current data through the chatbot.

In practical applications such as research, customer support, and knowledge retrieval, users often need up-to-date information. Traditional chatbots fail to provide accurate answers for recent events or dynamic content available on the web.

Therefore, there is a need for a chatbot that can intelligently search the internet and provide real-time information to the user.

Our Solution

To solve this problem, we developed an AI chatbot with an integrated Web Search Agent.

The chatbot allows users to enable a Web Search Mode. When this mode is enabled, the chatbot automatically performs a web search for the user’s query and retrieves relevant information from the internet.

The system uses the Tavily Search API to fetch search results and the AI model processes and summarizes the information before presenting it to the user.

This approach enables the chatbot to provide accurate, real-time, and context-aware responses, improving the usefulness of the system for users.

Solution Architecture

The system follows an AI agent architecture where the chatbot decides when to use an external tool.

Workflow:

  1. The user sends a query through the chatbot interface.
  2. The AI agent analyzes the request.
  3. If Web Search Mode is enabled, the AI triggers the Web Search Tool.
  4. The system calls the Tavily API to retrieve relevant search results.
  5. The AI processes the results and generates a summarized response.
  6. The chatbot returns the final answer to the user.

Architecture Flow

User → Chat Interface → LangGraph Agent → Web Search Tool → Tavily API → AI Processing → Response to User

Deliverables

  1. AI chatbot interface capable of interacting with users.
  2. Web Search feature integrated into the chatbot.
  3. Toggle option to enable or disable Web Search Mode.
  4. Integration with Tavily API for real-time search results.
  5. AI-generated summaries of search results.
  6. Functional prototype demonstrating AI tool-based behavior.

Tech Stack

TechnologyPurposeWhy chosen
Tavily Search APIReal-time web searchLangGraph’s official recommended search API, free 1000/month
Groq API (Llama 3.3 70B)LLM — answer generation from search resultsFree tier, ultra-fast streaming inference
Next.js 16 API RoutesBackend — /api/websearch endpointSSE streaming support built-in
SSE (Server-Sent Events)Real-time token streaming to browserNative browser support, no WebSocket needed
React useState / useRefMode state, chat state, streaming updatesReal-time UI updates without page reload
Tailwind CSS v4Source chip styling, hover effectsUtility-first, easy hover/transition classes
TypeScriptType safety for Chat type with sources fieldPrevents runtime errors in streaming logic

Business Impact

  • The developed solution demonstrates how AI chatbots can be enhanced with external tools to provide real-time information.
  • This type of system can benefit multiple industries, including:
  • Customer Support
    Companies can use AI chatbots that retrieve the latest product information or troubleshooting solutions from the web.
  • Research and Knowledge Platforms
    Users can quickly obtain updated information without manually searching multiple websites.
  • Education Sector
    Students can ask questions and receive summarized explanations from current online resources.
  • Business Intelligence
    Organizations can monitor trends, news, and industry updates using AI-powered assistants.
  • Overall, integrating web search with AI agents improves the accuracy, usefulness, and real-time capabilities of chatbot systems.