n8n

Connect an assistant to an n8n workflow through an API Request tool

Use an API Request tool when an assistant needs a result from an n8n workflow during a conversation. Vapi calls the workflow’s production Webhook URL and gives its JSON response to the assistant.

What is n8n

n8n is a workflow automation platform that connects services and processes data. Its Webhook node can receive an HTTP request, run a workflow, and return data to Vapi. This pattern does not require a Vapi-specific request or response envelope.

Connect n8n

The Vapi + n8n starter demonstrates a three-node request-response workflow: Webhook → Code → Respond to Webhook. It checks an editable business-hours schedule and returns whether the example business is open now.

Prerequisites

  • A Vapi account and a private API key
  • An n8n instance that can publish a workflow with an HTTPS Webhook URL
  • Node.js 20.6 or newer to run the starter
1

Get the starter

Clone the Vapi Labs repository, then open the starter directory:

git clone https://github.com/VapiAI/vapi-labs.git
cd vapi-labs/projects/vapi-n8n-api-request-starter
2

Import the workflow

In the n8n workflow editor, open the top-right three-dot menu, select Import from File, and choose workflows/vapi-business-hours.json from the starter directory.

3

Set the example schedule

Open Check business hours and set timeZone, openDays, opensAt, and closesAt for your example business. The imported workflow uses Monday through Friday, 09:00–17:00 in America/Los_Angeles.

4

Publish the workflow

Select Publish. Open Receive Vapi request, select Production URL, and copy the HTTPS URL. The Test URL works only while n8n is listening for a test event; use the production URL for the Vapi tool.

5

Configure the starter

From projects/vapi-n8n-api-request-starter, copy .env.example to .env.local. Set VAPI_API_KEY to your Vapi private API key and N8N_WEBHOOK_URL to the n8n production URL. Keep .env.local private.

cp .env.example .env.local
6

Run the starter

From the same directory, run:

node --env-file=.env.local scripts/run.mjs

The runner uses a transient assistant and an inline API Request tool. You do not need to create a saved tool or assistant in the Vapi Dashboard.

Verify the result

A successful run prints n8n webhook OK, Vapi API Request confirmed, and a Vapi answer based on the returned hours. The open or closed result depends on the current time and the schedule you set. In n8n, open the workflow’s Executions tab to inspect production requests.

The response includes openNow, localTime, timeZone, the regular schedule, and checkedAt. The example does not account for holidays or appointment availability.

Settings reference

SettingStarter valueWhy it matters
n8n Webhook HTTP MethodGETMust match the API Request tool’s method.
n8n Webhook RespondUsing ‘Respond to Webhook’ NodeReturns the workflow’s JSON result instead of an immediate acknowledgment.
n8n Respond to Webhook Respond WithJSONMakes the business-hours fields available to the assistant.
Vapi API Request tool urln8n Production URLThe runner inserts this URL from N8N_WEBHOOK_URL.
Vapi API Request tool timeoutSeconds10The workflow must return before the tool times out.

Choose another pattern

NeedVapi patternn8n behavior
Use workflow data or an action result during the conversationAPI Request toolReceive the request and return JSON in the same HTTP response.
Send call events or an end-of-call report to n8nServer URLReceive Vapi events with a Webhook node; an informational event does not return a tool result to the assistant.
Receive Vapi’s tool-calls payload or use asynchronous tool executionFunction toolParse the Vapi payload and return the Function tool’s required response when synchronous.

Authenticate private workflows

Keep authentication secrets out of exported workflow JSON and model-visible tool fields.

The starter uses an unauthenticated webhook for public example hours. For private data or actions, configure n8n Webhook Header Auth and a Vapi Custom Credential with a matching header name and value.

Set the inline API Request tool’s credentialId to the credential ID. If n8n expects the raw header value, disable the credential’s Bearer prefix.

The starter does not test this authenticated variant. Its preflight GET request sends no authentication header, so the unchanged runner fails against a protected webhook. Add the same header to the preflight request when testing this variant.

Troubleshoot the connection

SymptomCheck first
n8n returns 404 or the webhook is not registeredPublish the workflow and use its Production URL, not the Test URL.
Vapi receives an acknowledgment instead of business-hours fieldsSet the Webhook node to respond using Respond to Webhook, and return JSON from that node.
Vapi reports a failed requestCheck the n8n execution for an error or non-2xx response. See API Request response handling.
The assistant waits too longCheck n8n execution time against timeoutSeconds. See API Request latency and retries.
The assistant does not call the toolCheck that the assistant prompt asks it to use the tool for current hours. See Troubleshoot tools.

When you finish testing, unpublish the n8n workflow to stop accepting production webhook requests. The starter creates no saved Vapi resources.