{
  "workflow": {
    "id": 4036,
    "name": "Claude 3.7 Sonnet AI chatbot agent with Anthropic web search and think functions",
    "views": 2982,
    "recentViews": 1,
    "totalViews": 2982,
    "createdAt": "2025-05-14T09:17:36.639Z",
    "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**:\n\n* **Real-time web search**, to answer up-to-date factual queries.\n* A **“Think” function**, to support internal reasoning and memory-like behavior by Anthropic.\n* A **memory buffer**, allowing the agent to maintain conversation history.\n* A **system prompt** defining clear ethical, functional, and formatting rules for interaction.\n\nWhen 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.\n\n---\n\n### ✅ **Advantages**\n\n* **🧠 Enhanced Reasoning Abilities**\n  The *Think* tool allows the agent to simulate deep thought processes or contextual memory storage, improving conversational intelligence.\n\n* **🌐 Real-Time Knowledge via Web Search**\n  The integrated `web_search` tool enables the agent to fetch the latest information from the internet, making it ideal for dynamic or news-driven use cases.\n\n* **🧾 Contextual Responses with Memory Buffer**\n  The inclusion of a memory buffer allows the agent to maintain state across messages, improving dialogue flow and continuity.\n\n* **🛡️ Built-in Ethical Guidelines**\n  The system prompt enforces privacy, factual integrity, neutrality, and ethical response generation, making the agent safe for public or enterprise use.\n\n\n---\n\n### How It Works\n\n1. **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.  \n2. **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:  \n   - For website-related queries, it uses the provided context.  \n   - For external information, it employs the `web_search` tool to fetch up-to-date data from the internet.  \n   - The `Think` tool is used for internal reasoning or caching thoughts without altering data.  \n3. **Language Model**: The Anthropic Chat Model (Claude 3.7 Sonnet) generates responses based on the analyzed query, incorporating website context or web search results.  \n4. **Memory**: A simple memory buffer retains context from previous interactions to maintain continuity in conversations.  \n5. **Output**: The final response is delivered to the user, excluding internal processes like web searches or reasoning steps.  \n\n--- \n### Set Up Steps\n\n1. **Configure Nodes**:  \n   - **Chat Trigger**: Set up the webhook to receive user messages.  \n   - **AI Agent**: Define the system message and rules for handling queries.  \n   - **Anthropic Chat Model**: Select the Claude 3.7 Sonnet model and configure parameters like `maxTokensToSample`.  \n   - **Memory**: Initialize the memory buffer to store conversation context.  \n   - **Tools**:  \n     - `web_search`: Configure the HTTP request to the Anthropic API for web searches, including headers and authentication.  \n     - `Think`: Set up the tool for internal reasoning.  \n\n2. **Connect Nodes**:  \n   - Link the Chat Trigger to the AI Agent.  \n   - Connect the Anthropic Chat Model, Memory, and Tools (`web_search` and `Think`) to the AI Agent.  \n\n3. **Credentials**:  \n   - Ensure the Anthropic API credentials are correctly configured for both the chat model and the `web_search` tool.  \n\n---\n\n### **Need help customizing?**  \n[Contact me](mailto:info@n3w.it) for consulting and support or add me on [Linkedin](https://www.linkedin.com/in/davideboizza/). \n",
    "workflow": {
      "id": "tnR20GpQTEWVMayy",
      "meta": {
        "instanceId": "a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462",
        "templateCredsSetupCompleted": true
      },
      "name": "Claude 3.7 Sonnet AI Agent with web search and Think functions",
      "tags": [],
      "nodes": [
        {
          "id": "28388e6f-3dfc-4e2b-a367-81104c4ef8af",
          "name": "When chat message received",
          "type": "@n8n/n8n-nodes-langchain.chatTrigger",
          "position": [
            -220,
            -140
          ],
          "webhookId": "095537c6-b21a-4cb2-8312-13b1bf1699dc",
          "parameters": {
            "options": {}
          },
          "typeVersion": 1.1
        },
        {
          "id": "abd6690f-cbf7-4b47-bba9-6856da348d33",
          "name": "AI Agent",
          "type": "@n8n/n8n-nodes-langchain.agent",
          "position": [
            0,
            -140
          ],
          "parameters": {
            "options": {
              "systemMessage": "=You are an AI-powered chatbot assistant for a website. Your primary function is to assist users by answering their queries and providing relevant information. You have access to a web_search tool that allows you to browse the internet for up-to-date information. Here's how you should operate:\n\n1. Website Information:\nFamiliarize yourself with this information about the website you're assisting. Use this as context for user interactions.\n\n2. Web Search Tool:\nYou have access to a web_search tool that can browse the internet. To use it, write the variable {web_search_question}. The tool will return relevant search results.\n\n3. Handling User Queries:\nWhen a user asks a question, follow these steps:\na) Analyze the query to determine if it's related to the website or requires external information.\nb) If the query is about the website, use the provided website information to answer.\nc) If external information is needed, use the web_search tool to find relevant data.\n\n4. Using web_search:\n- Use web_search for factual, current information that isn't provided in the website info.\n- Formulate clear, concise search queries.\n- If the first search doesn't yield useful results, refine your query and search again.\n- Limit searches to a maximum of three per user query to maintain efficiency.\n\n5. Using Think:\n- Using Think tool to think about something. It will not obtain new information or change the database, but just append the thought to the log. Use it when complex reasoning or some cache memory is needed.\n\n6. Formulating Responses:\n- Begin with information from the website if relevant.\n- Incorporate web search results to provide up-to-date, accurate information.\n- Summarize findings concisely and coherently.\n- If you're unsure or can't find reliable information, be honest about limitations.\n\n7. Ethical Considerations:\n- Respect user privacy. Don't ask for or store personal information.\n- Provide factual information. Avoid speculation or unverified claims.\n- If asked about controversial topics, strive for a balanced, neutral response.\n- Don't engage in or encourage illegal activities.\n\n8. Output Format:\nDo not include your thought process, web searches, or any other tags in the final output.\n"
            }
          },
          "typeVersion": 1.9
        },
        {
          "id": "f862db48-2498-4e8d-8eab-0ecb3d06e5a8",
          "name": "Anthropic Chat Model",
          "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
          "position": [
            -80,
            80
          ],
          "parameters": {
            "model": {
              "__rl": true,
              "mode": "list",
              "value": "claude-3-7-sonnet-20250219",
              "cachedResultName": "Claude 3.7 Sonnet"
            },
            "options": {
              "maxTokensToSample": 1024
            }
          },
          "credentials": {
            "anthropicApi": {
              "id": "credential-id",
              "name": "anthropicApi Credential"
            }
          },
          "typeVersion": 1.3
        },
        {
          "id": "ced144d4-465c-4a8f-8822-97a93111077e",
          "name": "Simple Memory",
          "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
          "position": [
            80,
            80
          ],
          "parameters": {},
          "typeVersion": 1.3
        },
        {
          "id": "93e6bfb3-6a95-4ecf-af39-aad3ca6019a0",
          "name": "web_search",
          "type": "n8n-nodes-base.httpRequestTool",
          "position": [
            200,
            80
          ],
          "parameters": {
            "url": "https://api.anthropic.com/v1/messages",
            "method": "POST",
            "options": {},
            "jsonBody": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('JSON', `{\n  \"model\": \"claude-3-7-sonnet-latest\",\n  \"max_tokens\": 1024,\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"{web_search_question}\"\n    }\n  ],\n  \"tools\": [\n    {\n      \"type\": \"web_search_20250305\",\n      \"name\": \"web_search\",\n      \"max_uses\": 5\n    }\n  ]\n}\n`, 'json') }}",
            "sendBody": true,
            "sendHeaders": true,
            "specifyBody": "json",
            "authentication": "predefinedCredentialType",
            "toolDescription": "Use this tool to search on the web",
            "headerParameters": {
              "parameters": [
                {
                  "name": "anthropic-version",
                  "value": "2023-06-01"
                },
                {
                  "name": "content-type",
                  "value": "application/jso"
                }
              ]
            },
            "nodeCredentialType": "anthropicApi"
          },
          "credentials": {
            "anthropicApi": {
              "id": "credential-id",
              "name": "anthropicApi Credential"
            },
            "httpHeaderAuth": {
              "id": "credential-id",
              "name": "httpHeaderAuth Credential"
            }
          },
          "typeVersion": 4.2
        },
        {
          "id": "00335b1e-03b2-4c6c-993a-b452e265cdeb",
          "name": "Think",
          "type": "@n8n/n8n-nodes-langchain.toolThink",
          "position": [
            320,
            80
          ],
          "parameters": {},
          "typeVersion": 1
        },
        {
          "id": "0c493a57-65fa-48b4-a3b3-944b052a4dd5",
          "name": "Sticky Note",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            -220,
            -340
          ],
          "parameters": {
            "width": 620,
            "content": "## Claude 3.7 Sonnet AI Agent with web search and Think functions\nThis 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**."
          },
          "typeVersion": 1
        }
      ],
      "active": false,
      "pinData": {},
      "settings": {
        "executionOrder": "v1"
      },
      "versionId": "0e13b1bb-4231-4d18-80ac-fa155f084a6d",
      "connections": {
        "Think": {
          "ai_tool": [
            [
              {
                "node": "AI Agent",
                "type": "ai_tool",
                "index": 0
              }
            ]
          ]
        },
        "web_search": {
          "ai_tool": [
            [
              {
                "node": "AI Agent",
                "type": "ai_tool",
                "index": 0
              }
            ]
          ]
        },
        "Simple Memory": {
          "ai_memory": [
            [
              {
                "node": "AI Agent",
                "type": "ai_memory",
                "index": 0
              }
            ]
          ]
        },
        "Anthropic Chat Model": {
          "ai_languageModel": [
            [
              {
                "node": "AI Agent",
                "type": "ai_languageModel",
                "index": 0
              }
            ]
          ]
        },
        "When chat message received": {
          "main": [
            [
              {
                "node": "AI Agent",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    },
    "lastUpdatedBy": 29,
    "workflowInfo": {
      "nodeCount": 7,
      "nodeTypes": {
        "n8n-nodes-base.stickyNote": {
          "count": 1
        },
        "@n8n/n8n-nodes-langchain.agent": {
          "count": 1
        },
        "n8n-nodes-base.httpRequestTool": {
          "count": 1
        },
        "@n8n/n8n-nodes-langchain.toolThink": {
          "count": 1
        },
        "@n8n/n8n-nodes-langchain.chatTrigger": {
          "count": 1
        },
        "@n8n/n8n-nodes-langchain.lmChatAnthropic": {
          "count": 1
        },
        "@n8n/n8n-nodes-langchain.memoryBufferWindow": {
          "count": 1
        }
      }
    },
    "status": "published",
    "user": {
      "name": "Davide",
      "username": "n3witalia",
      "bio": "Full-stack Web Developer based in Italy specialising in Marketing & AI-powered automations. For business enquiries, send me an email at info@n3w.it or add me on Linkedin.com/in/davideboizza",
      "verified": true,
      "links": [
        "https://n3w.it"
      ],
      "avatar": "https://gravatar.com/avatar/d41b8a0aa81139243509c58870f5b4be292824a507ab57d10ed066d8628ed8da?r=pg&d=retro&size=200"
    },
    "nodes": [
      {
        "id": 565,
        "icon": "fa:sticky-note",
        "name": "n8n-nodes-base.stickyNote",
        "codex": {
          "data": {
            "alias": [
              "Comments",
              "Notes",
              "Sticky"
            ],
            "categories": [
              "Core Nodes"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0",
            "subcategories": {
              "Core Nodes": [
                "Helpers"
              ]
            }
          }
        },
        "group": "[\"input\"]",
        "defaults": {
          "name": "Sticky Note",
          "color": "#FFD233"
        },
        "iconData": {
          "icon": "sticky-note",
          "type": "icon"
        },
        "displayName": "Sticky Note",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 9,
            "name": "Core Nodes"
          }
        ]
      },
      {
        "id": 1119,
        "icon": "fa:robot",
        "name": "@n8n/n8n-nodes-langchain.agent",
        "codex": {
          "data": {
            "alias": [
              "LangChain",
              "Chat",
              "Conversational",
              "Plan and Execute",
              "ReAct",
              "Tools"
            ],
            "resources": {
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent/"
                }
              ]
            },
            "categories": [
              "AI",
              "Langchain"
            ],
            "subcategories": {
              "AI": [
                "Agents",
                "Root Nodes"
              ]
            }
          }
        },
        "group": "[\"transform\"]",
        "defaults": {
          "name": "AI Agent",
          "color": "#404040"
        },
        "iconData": {
          "icon": "robot",
          "type": "icon"
        },
        "displayName": "AI Agent",
        "typeVersion": 3,
        "nodeCategories": [
          {
            "id": 25,
            "name": "AI"
          },
          {
            "id": 26,
            "name": "Langchain"
          }
        ]
      },
      {
        "id": 1145,
        "icon": "file:anthropic.svg",
        "name": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
        "codex": {
          "data": {
            "alias": [
              "claude",
              "sonnet",
              "opus"
            ],
            "resources": {
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatanthropic/"
                }
              ]
            },
            "categories": [
              "AI",
              "Langchain"
            ],
            "subcategories": {
              "AI": [
                "Language Models",
                "Root Nodes"
              ],
              "Language Models": [
                "Chat Models (Recommended)"
              ]
            }
          }
        },
        "group": "[\"transform\"]",
        "defaults": {
          "name": "Anthropic Chat Model"
        },
        "iconData": {
          "type": "file",
          "fileBuffer": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0NiIgaGVpZ2h0PSIzMiIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iIzdEN0Q4NyIgZD0iTTMyLjczIDBoLTYuOTQ1TDM4LjQ1IDMyaDYuOTQ1ek0xMi42NjUgMCAwIDMyaDcuMDgybDIuNTktNi43MmgxMy4yNWwyLjU5IDYuNzJoNy4wODJMMTkuOTI5IDB6bS0uNzAyIDE5LjMzNyA0LjMzNC0xMS4yNDYgNC4zMzQgMTEuMjQ2eiIvPjwvc3ZnPg=="
        },
        "displayName": "Anthropic Chat Model",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 25,
            "name": "AI"
          },
          {
            "id": 26,
            "name": "Langchain"
          }
        ]
      },
      {
        "id": 1163,
        "icon": "fa:database",
        "name": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
        "codex": {
          "data": {
            "resources": {
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.memorybufferwindow/"
                }
              ]
            },
            "categories": [
              "AI",
              "Langchain"
            ],
            "subcategories": {
              "AI": [
                "Memory"
              ],
              "Memory": [
                "For beginners"
              ]
            }
          }
        },
        "group": "[\"transform\"]",
        "defaults": {
          "name": "Simple Memory"
        },
        "iconData": {
          "icon": "database",
          "type": "icon"
        },
        "displayName": "Simple Memory",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 25,
            "name": "AI"
          },
          {
            "id": 26,
            "name": "Langchain"
          }
        ]
      },
      {
        "id": 1247,
        "icon": "fa:comments",
        "name": "@n8n/n8n-nodes-langchain.chatTrigger",
        "codex": {
          "data": {
            "resources": {
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.chattrigger/"
                }
              ]
            },
            "categories": [
              "Core Nodes",
              "Langchain"
            ]
          }
        },
        "group": "[\"trigger\"]",
        "defaults": {
          "name": "When chat message received"
        },
        "iconData": {
          "icon": "comments",
          "type": "icon"
        },
        "displayName": "Chat Trigger",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 9,
            "name": "Core Nodes"
          },
          {
            "id": 26,
            "name": "Langchain"
          }
        ]
      },
      {
        "id": 1289,
        "icon": "fa:brain",
        "name": "@n8n/n8n-nodes-langchain.toolThink",
        "codex": {
          "data": {
            "resources": {
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolthink/"
                }
              ]
            },
            "categories": [
              "AI",
              "Langchain"
            ],
            "subcategories": {
              "AI": [
                "Tools"
              ],
              "Tools": [
                "Other Tools"
              ]
            }
          }
        },
        "group": "[\"transform\"]",
        "defaults": {
          "name": "Think"
        },
        "iconData": {
          "icon": "brain",
          "type": "icon"
        },
        "displayName": "Think Tool",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 25,
            "name": "AI"
          },
          {
            "id": 26,
            "name": "Langchain"
          }
        ]
      }
    ],
    "categories": [
      {
        "id": 40,
        "name": "Support Chatbot"
      },
      {
        "id": 47,
        "name": "AI Chatbot"
      }
    ],
    "image": []
  }
}