π¬ Claude 3.7 Sonnet AI chatbot agent with Anthropic web search and think functions
β‘ 3,223 views Β· π¬ Support Chatbots
Description
This workflow builds a conversational AI chatbot agent using Claude 3.7 Sonnet model with the new . It enhances standard LLM capabilities with Anthropicβs features: Web Search and Think:
- Real-time web search, to answer up-to-date factual queries.
- A βThinkβ function, to support internal reasoning and memory-like behavior by Anthropic.
- A memory buffer, allowing the agent to maintain conversation history.
- A system prompt defining clear ethical, functional, and formatting rules for interaction.
When a user sends a message (trigger), the chatbot evaluates the query, optionally performs a web search if needed, processes the result using Claude, and responds accordingly.
β Advantages
-
π§ Enhanced Reasoning Abilities The Think tool allows the agent to simulate deep thought processes or contextual memory storage, improving conversational intelligence.
-
π Real-Time Knowledge via Web Search The integrated
web_searchtool enables the agent to fetch the latest information from the internet, making it ideal for dynamic or news-driven use cases. -
π§Ύ Contextual Responses with Memory Buffer The inclusion of a memory buffer allows the agent to maintain state across messages, improving dialogue flow and continuity.
-
π‘οΈ Built-in Ethical Guidelines The system prompt enforces privacy, factual integrity, neutrality, and ethical response generation, making the agent safe for public or enterprise use.
How It Works
- Chat Trigger: The workflow begins when a chat message is received via a webhook. This triggers the AI Agent to process the userβs query.
- AI Agent Processing: The AI Agent analyzes the query to determine if it requires information from the website or external sources. It follows a structured approach:
- For website-related queries, it uses the provided context.
- For external information, it employs the
web_searchtool to fetch up-to-date data from the internet. - The
Thinktool is used for internal reasoning or caching thoughts without altering data.
- Language Model: The Anthropic Chat Model (Claude 3.7 Sonnet) generates responses based on the analyzed query, incorporating website context or web search results.
- Memory: A simple memory buffer retains context from previous interactions to maintain continuity in conversations.
- Output: The final response is delivered to the user, excluding internal processes like web searches or reasoning steps.
Set Up Steps
-
Configure Nodes:
- Chat Trigger: Set up the webhook to receive user messages.
- AI Agent: Define the system message and rules for handling queries.
- Anthropic Chat Model: Select the Claude 3.7 Sonnet model and configure parameters like
maxTokensToSample. - Memory: Initialize the memory buffer to store conversation context.
- Tools:
web_search: Configure the HTTP request to the Anthropic API for web searches, including headers and authentication.Think: Set up the tool for internal reasoning.
-
Connect Nodes:
- Link the Chat Trigger to the AI Agent.
- Connect the Anthropic Chat Model, Memory, and Tools (
web_searchandThink) to the AI Agent.
-
Credentials:
- Ensure the Anthropic API credentials are correctly configured for both the chat model and the
web_searchtool.
- Ensure the Anthropic API credentials are correctly configured for both the chat model and the
Need help customizing?
Contact me for consulting and support or add me on Linkedin.
π Nodes Used
AI Agent, Anthropic Chat Model, Simple Memory, Chat Trigger, Think Tool
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File