Build AI Agents That Call APIs with n8n's HTTP Request Tool and OpenAI

This template is a hands-on introduction to the HTTP Request Tool in n8n's LangChain nodes, showing how an AI Agent backed by an OpenAI chat model can call arbitrary REST APIs without you wiring up a sub-workflow for every endpoint. It runs two parallel demos in the same canvas: one agent scrapes GitHub issues through the Firecrawl API, and a second agent suggests an activity by calling the public Bored API. It's aimed at builders who already understand agents and want to replace bulky Execute Workflow Tool patterns with a single configurable HTTP tool.

How It Works

A single When clicking 'Test workflow' manual trigger fans out to both demos in parallel. Branch one passes through Set ChatInput, which hardcodes the prompt "Can get the latest 10 issues from https://github.com/n8n-io/n8n/issues?" into a chatInput field, then hands off to the AI Agent node. That agent is wired to two sub-nodes via the ai_languageModel and ai_tool ports: OpenAI Chat Model supplies the reasoning, and Webscraper Tool (an HTTP Request Tool) exposes a POST call to https://api.firecrawl.dev/v0/scrape with onlyMainContent and tag-stripping options, so the agent can fetch a clean Markdown rendering of any URL it decides to scrape.

Branch two mirrors the structure: Set ChatInput1 seeds the prompt "Hi! Please suggest something to do. I feel like learning something new!", then AI Agent1 uses OpenAI Chat Model1 plus the Activity Tool. That tool is a GET to https://bored-api.appbrewery.com/filter with declared query parameters type and participants; the agent decides at runtime what values to pass based on the chat input. Because the HTTP Request Tool's toolDescription tells the LLM exactly which parameters to populate, no manual query-param node is needed.

Nodes Included

  • When clicking 'Test workflow' — manual trigger that kicks off both demo branches in one execution.
  • Set ChatInput — hardcodes the GitHub-issues prompt into chatInput for the scraping agent.
  • Set ChatInput1 — hardcodes the activity-suggestion prompt for the second agent.
  • AI Agent / AI Agent1 — LangChain agent nodes that consume the chat input and decide which tool to call.
  • OpenAI Chat Model / OpenAI Chat Model1 — the LLM brain attached to each agent over the ai_languageModel port.
  • Webscraper Tool — HTTP Request Tool pointed at Firecrawl's /v0/scrape endpoint, used as an ai_tool for the first agent.
  • Activity Tool — HTTP Request Tool pointed at the Bored API's /filter endpoint, used as an ai_tool for the second agent.
  • Sticky Note / Sticky Note1 / Sticky Note2 — on-canvas documentation explaining each demo and linking to the n8n Discord and Forum.

Setting Up Credentials

This workflow connects to two external services that need credentials: OpenAI for the chat models and Firecrawl for the web scraper. The Bored API is public and requires no auth.

OpenAI

  1. Sign in at platform.openai.com and confirm your account has billing enabled under Settings -> Billing.
  2. Open platform.openai.com/api-keys and click Create new secret key. Give it a descriptive name like n8n-http-tool-demo and copy the sk-... value once — it's only shown to you on creation.
  3. Optionally scope the key to a specific project from the project dropdown in the top-left so usage shows up separately in billing.
  4. In n8n, open both OpenAI Chat Model and OpenAI Chat Model1, click the credential dropdown, choose Create New, pick credential type "OpenAI API", paste the key, and save. Both nodes can share the same credential.

Firecrawl (HTTP Header Auth)

  1. Sign up at firecrawl.dev and verify your email.
  2. Open the dashboard at firecrawl.dev/app and copy the API Key from the API Keys section (it begins with fc-).
  3. In n8n, open the Webscraper Tool node. Its genericAuthType is already set to httpHeaderAuth. Click the credential dropdown, choose Create New, and pick credential type "Header Auth".
  4. Set Name to Authorization and Value to Bearer fc-your-key-here, then save and select the new credential on the node.
  5. Note: the template references Firecrawl's /v0/scrape endpoint. If you sign up today you'll likely have access to the /v1/scrape API, which uses a slightly different payload shape — confirm the current endpoint in Firecrawl's docs before running.

Customizing the Workflow

Swap the manual trigger for a Chat Trigger and remove the Set ChatInput nodes so users can ask the agents anything from a chat UI instead of running a single hardcoded prompt. Replace the Bored API endpoint in Activity Tool with any GET-style API you want the agent to query — for example a weather or stock-quote endpoint — and rewrite the toolDescription so the LLM knows when and how to use it. To run cheaper experiments, point both OpenAI Chat Models at gpt-4o-mini in the model selector and lower the temperature.

Common Issues

  • If the agent ignores your tool, it's almost always because the toolDescription is vague. Be explicit about when to call the tool and what each parameter means, just like the Activity Tool's enum-style description of the type field.
  • The HTTP Request Tool node requires n8n v1.47.0 or newer. On older self-hosted instances the node will appear as unknown on import — upgrade the instance or rebuild the tool via a sub-workflow.
12 nodesmanual trigger218 views0 copiesOther
OpenAI

Workflow JSON

{"meta": {"instanceId": "26ba763460b97c249b82942b23b6384876dfeb9327513332e743c5f6219c2b8e"}, "nodes": [{"id": "abccacce-bbdc-428e-94e0-19996c5bfe02", "name": "Sticky Note", "type": "n8n-nodes-base.stickyNote", "position": [1720, 160], "parameters": {"color": 7, "width": 319.5392879244982, "height": 218.88813194060202, "content": "### AI agent that can scrape webpages\nRemake of https://n8n.io/workflows/2006-ai-agent-that-can-scrape-webpages/\n\n**Changes**:\n* Replaces Execute Workflow Tool and Subworkflow\n* Replaces Response Formatting"}, "typeVersion": 1}, {"id": "9fc05c79-5a2d-4ac4-a4f5-32b9c1b385e1", "name": "OpenAI Chat Model", "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", "position": [1340, 340], "parameters": {"options": {}}, "credentials": {"openAiApi": {"id": "", "name": "[Your openAiApi]"}}, "typeVersion": 1}, {"id": "45c9bdaf-d51e-4026-8911-4b04c5473b06", "name": "Sticky Note1", "type": "n8n-nodes-base.stickyNote", "position": [1720, 560], "parameters": {"color": 7, "width": 365.9021913627245, "height": 245.35379866205295, "content": "### Allow your AI to call an API to fetch data\nRemake of https://n8n.io/workflows/2094-allow-your-ai-to-call-an-api-to-fetch-data/\n\n**Changes**:\n* Replaces Execute Workflow Tool and Subworkflow\n* Replaces Manual Query Params Definitions\n* Replaces Response Formatting"}, "typeVersion": 1}, {"id": "bc1754e6-01f4-4561-8814-c08feb45acec", "name": "OpenAI Chat Model1", "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", "position": [1340, 740], "parameters": {"options": {}}, "credentials": {"openAiApi": {"id": "", "name": "[Your openAiApi]"}}, "typeVersion": 1}, {"id": "a40230ae-6050-4bb8-b275-3a893dc3ad98", "name": "Activity Tool", "type": "@n8n/n8n-nodes-langchain.toolHttpRequest", "position": [1560, 740], "parameters": {"url": "https://bored-api.appbrewery.com/filter", "sendQuery": true, "parametersQuery": {"values": [{"name": "type"}, {"name": "participants"}]}, "toolDescription": "Call this tool to suggest an activity where:\n* the parameter \"type\" is one of \"education\", \"recreational\",\"social\",\"diy\",\"charity\",\"cooking\",\"relaxation\",\"music\",\"busywork\"\n* the parameter \"participants\" is the number of participants for the activity"}, "typeVersion": 1}, {"id": "297377e0-e149-4786-b521-82670ac390a7", "name": "Set ChatInput1", "type": "n8n-nodes-base.set", "position": [1180, 560], "parameters": {"options": {}, "assignments": {"assignments": [{"id": "e976bf5f-8803-4129-9136-115b3d15755c", "name": "chatInput", "type": "string", "value": "Hi! Please suggest something to do. I feel like learning something new!"}]}}, "typeVersion": 3.4}, {"id": "a9128da1-4486-4a17-b9b3-64ebc402348d", "name": "AI Agent1", "type": "@n8n/n8n-nodes-langchain.agent", "position": [1360, 560], "parameters": {"text": "={{ $json.chatInput }}", "options": {}, "promptType": "define"}, "typeVersion": 1.6}, {"id": "28a5e75e-e32d-4c94-bea2-7347923e6bb9", "name": "Set ChatInput", "type": "n8n-nodes-base.set", "position": [1160, 160], "parameters": {"options": {}, "assignments": {"assignments": [{"id": "9695c156-c882-4e43-8a4e-70fbdc1a63de", "name": "chatInput", "type": "string", "value": "Can get the latest 10 issues from https://github.com/n8n-io/n8n/issues?"}]}}, "typeVersion": 3.4}, {"id": "d29b30fb-7edb-4665-bc6b-a511caf9db9f", "name": "When clicking \u2018Test workflow\u2019", "type": "n8n-nodes-base.manualTrigger", "position": [900, 400], "parameters": {}, "typeVersion": 1}, {"id": "066f9cdd-4bd3-48a1-bf9b-32eda3e28945", "name": "AI Agent", "type": "@n8n/n8n-nodes-langchain.agent", "position": [1360, 160], "parameters": {"text": "={{ $json.chatInput }}", "options": {}, "promptType": "define"}, "typeVersion": 1.6}, {"id": "fb4abae8-7e38-47b7-9595-403e523f7125", "name": "Webscraper Tool", "type": "@n8n/n8n-nodes-langchain.toolHttpRequest", "position": [1560, 340], "parameters": {"url": "https://api.firecrawl.dev/v0/scrape", "fields": "markdown", "method": "POST", "sendBody": true, "dataField": "data", "authentication": "genericCredentialType", "parametersBody": {"values": [{"name": "url"}, {"name": "pageOptions", "value": "={{ {\n onlyMainContent: true,\n replaceAllPathsWithAbsolutePaths: true,\n removeTags: 'img,svg,video,audio'\n} }}", "valueProvider": "fieldValue"}]}, "fieldsToInclude": "selected", "genericAuthType": "httpHeaderAuth", "toolDescription": "Call this tool to fetch a webpage content.", "optimizeResponse": true}, "credentials": {"httpHeaderAuth": {"id": "", "name": "[Your httpHeaderAuth]"}}, "typeVersion": 1}, {"id": "73d3213c-1ecb-4007-b882-1cc756a6f6e0", "name": "Sticky Note2", "type": "n8n-nodes-base.stickyNote", "position": [420, 120], "parameters": {"width": 413.82332632615135, "height": 435.92895157500243, "content": "## Try It Out!\n\n### The HTTP tool is drastically simplifies API-enabled AI agents cutting down the number of workflow nodes by as much as 10!\n\n* Available since v1.47.0\n* Recommended for single purpose APIs which don't require much post-fetch formatting.\n* If you require a chain of API calls, you may need to implement a subworkflow instead.\n\n### Need Help?\nJoin the [Discord](https://discord.com/invite/XPKeKXeB7d) or ask in the [Forum](https://community.n8n.io/)!\n\nHappy Hacking!"}, "typeVersion": 1}], "pinData": {}, "connections": {"Activity Tool": {"ai_tool": [[{"node": "AI Agent1", "type": "ai_tool", "index": 0}]]}, "Set ChatInput": {"main": [[{"node": "AI Agent", "type": "main", "index": 0}]]}, "Set ChatInput1": {"main": [[{"node": "AI Agent1", "type": "main", "index": 0}]]}, "Webscraper Tool": {"ai_tool": [[{"node": "AI Agent", "type": "ai_tool", "index": 0}]]}, "OpenAI Chat Model": {"ai_languageModel": [[{"node": "AI Agent", "type": "ai_languageModel", "index": 0}]]}, "OpenAI Chat Model1": {"ai_languageModel": [[{"node": "AI Agent1", "type": "ai_languageModel", "index": 0}]]}, "When clicking \u2018Test workflow\u2019": {"main": [[{"node": "Set ChatInput", "type": "main", "index": 0}, {"node": "Set ChatInput1", "type": "main", "index": 0}]]}}}

How to Import This Workflow

  1. 1Copy the workflow JSON above using the Copy Workflow JSON button.
  2. 2Open your n8n instance and go to Workflows.
  3. 3Click Import from JSON and paste the copied workflow.

Don't have an n8n instance? Start your free trial at n8nautomation.cloud

Related Templates

KB Tool - Confluence Knowledge Base

Quickly retrieve information from your Confluence knowledge base with this n8n workflow. It connects to your Confluence instance via an HTTP Request node, allowing you to query for specific content directly from n8n. This workflow is ideal for support teams needing to rapidly access articles, developers looking up documentation, or anyone who frequently references Confluence pages and wants to integrate that data into other automated processes. By centralizing Confluence queries within n8n, you save significant time and effort previously spent manually navigating and searching, streamlining information retrieval and improving operational efficiency.

7 nodes

Analyze the sentiment of feedback and send a message on Mattermost

Automatically analyze customer feedback sentiment and notify your team on Mattermost with this n8n workflow. This automation connects Typeform submissions directly to Google Cloud Natural Language for sentiment analysis, then routes the results to your Mattermost channel. When a user submits a form through Typeform, the workflow extracts the feedback, sends it to Google Cloud Natural Language for sentiment scoring, and based on that score, sends a message to a designated Mattermost channel, allowing for immediate team awareness of positive, negative, or neutral feedback. This workflow is ideal for product managers, customer support teams, or marketing departments who need to quickly gauge public opinion or customer satisfaction from surveys, support tickets, or product reviews, enabling faster response times to critical feedback and reducing the manual effort of monitoring and reporting. It saves significant time and ensures that important customer insights are never missed, fostering a more responsive and customer-centric operation.

5 nodes

Hacker News Throwback Machine - See What Was Hot on This Day, Every Year!

Discover what was trending on Hacker News on this exact day, every year, with the Hacker News Throwback Machine. This n8n workflow automates the process of fetching historical Hacker News front pages and summarizing the top stories, delivering a daily dose of tech nostalgia directly to your Telegram chat. A Schedule Trigger initiates the workflow, which then dynamically generates a list of past years. For each year, it uses an HTTP Request node to retrieve the Hacker News front page for today's date, then an HTML Extract Details node parses the headlines and links. These headlines are then compiled and fed into a Google Gemini Chat Model via a Basic LLM Chain, which summarizes the most interesting stories. Finally, the summarized insights are sent to your designated Telegram chat, providing a unique historical perspective without any manual effort. This workflow is perfect for tech enthusiasts, developers, or anyone curious about the evolution of tech news, saving significant time and effort compared to manually searching through archives.

13 nodes

Ready to automate with n8n?

Get affordable managed n8n hosting with 24/7 support.