> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langbot.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Using n8n with LangBot

[n8n](https://n8n.io/) is an open-source workflow automation platform that allows you to create, schedule, and execute various automated tasks.

LangBot currently supports triggering workflows and receiving responses through the `Webhook` node in n8n workflows.

## Using n8n as the runner

Please open the configuration page of an existing pipeline or create a new pipeline (recommended) and open the configuration page. Select `n8n Workflow API` as the runner in `AI`.

<img src="https://mintcdn.com/langbot/OB26CZsqXqbSrW_A/images/zh/deploy/pipelines/n8n/config_runner.png?fit=max&auto=format&n=OB26CZsqXqbSrW_A&q=85&s=8aabbfef8ee447f87273fde0db508f39" alt="n8n as the runner" width="972" height="798" data-path="images/zh/deploy/pipelines/n8n/config_runner.png" />

Then configure and fill in the other settings according to the content below.

## Configuring n8n Workflow Connection

<img src="https://mintcdn.com/langbot/OB26CZsqXqbSrW_A/images/zh/deploy/pipelines/n8n/create_wf.png?fit=max&auto=format&n=OB26CZsqXqbSrW_A&q=85&s=731e8e15b71bfcacc99928aa9b503234" alt="n8n Workflow" width="1720" height="1220" data-path="images/zh/deploy/pipelines/n8n/create_wf.png" />

or

<img src="https://mintcdn.com/langbot/OB26CZsqXqbSrW_A/images/zh/deploy/pipelines/n8n/create_wf01.png?fit=max&auto=format&n=OB26CZsqXqbSrW_A&q=85&s=c57378002e70a90d244537ffd0b9c1da" alt="n8n Workflow" width="1891" height="904" data-path="images/zh/deploy/pipelines/n8n/create_wf01.png" />

Select `Webhook` or `On chat message` as the trigger and configure as follows:

* Webhook:
  <img src="https://mintcdn.com/langbot/OB26CZsqXqbSrW_A/images/zh/deploy/pipelines/n8n/config_webhook.png?fit=max&auto=format&n=OB26CZsqXqbSrW_A&q=85&s=31391afbbb3a90b39955410c00b9d162" alt="n8n webhook configuration" width="1720" height="1220" data-path="images/zh/deploy/pipelines/n8n/config_webhook.png" />
* On chat message:
  <img src="https://mintcdn.com/langbot/OB26CZsqXqbSrW_A/images/zh/deploy/pipelines/n8n/config_n8n_onchatmessage.png?fit=max&auto=format&n=OB26CZsqXqbSrW_A&q=85&s=518192be7a46338c3b1204d1d959569c" alt="n8n on chat message configuration" width="1543" height="900" data-path="images/zh/deploy/pipelines/n8n/config_n8n_onchatmessage.png" />

<Info title="">
  If you need streaming responses, set `Response Mode` to `Streaming`.

  <img src="https://mintcdn.com/langbot/OB26CZsqXqbSrW_A/images/zh/deploy/pipelines/n8n/config_response_model.png?fit=max&auto=format&n=OB26CZsqXqbSrW_A&q=85&s=4ca634d8727dad9ff2b9279d3b2a9ec7" alt="n8n streaming configuration" width="1046" height="873" data-path="images/zh/deploy/pipelines/n8n/config_response_model.png" />
</Info>

<Info title="">
  Authentication corresponds to the authentication methods in LangBot's pipeline configuration, which you can modify as needed.

  <img src="https://mintcdn.com/langbot/OB26CZsqXqbSrW_A/images/zh/deploy/pipelines/n8n/config_auth.png?fit=max&auto=format&n=OB26CZsqXqbSrW_A&q=85&s=023254bd4db3e3720cdda13ab1543d8d" alt="n8n workflow configuration" width="282" height="350" data-path="images/zh/deploy/pipelines/n8n/config_auth.png" />
</Info>

Configure the node that calls the AI model as `AI Agent`, following the setup below:

> For streaming responses, add the items highlighted in the red box. If you don't need streaming, you can skip this.

<img src="https://mintcdn.com/langbot/OB26CZsqXqbSrW_A/images/zh/deploy/pipelines/n8n/config_call_ai.png?fit=max&auto=format&n=OB26CZsqXqbSrW_A&q=85&s=f9fd69bdff58662066d77560ecc04fd8" alt="n8n AI model call configuration" width="1874" height="904" data-path="images/zh/deploy/pipelines/n8n/config_call_ai.png" />

For the workflow response content in n8n, please use the `Respond to Webhook` node and configure it according to the image below (if you choose streaming responses with the `AI Agent` node, you do not need this step):

<img src="https://mintcdn.com/langbot/OB26CZsqXqbSrW_A/images/zh/deploy/pipelines/n8n/config_respond.png?fit=max&auto=format&n=OB26CZsqXqbSrW_A&q=85&s=aa78274dfbadbf896ede3a86f4cab3b8" alt="n8n workflow response configuration" width="1720" height="1220" data-path="images/zh/deploy/pipelines/n8n/config_respond.png" />

The response content key name in `Response Body` needs to match the `output key name` in LangBot's pipeline configuration.

After completing the n8n workflow configuration, please click `Active` at the top to enable the workflow.
