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

# n8n

> Use Branch Pilot in an n8n workflow with the HTTP Request node, or with the community node when it lands.

<Note>
  A community node `n8n-nodes-branchpilot` (operations *Decide*, *Feedback*, *Get run*) is in preparation. Until it is published, the HTTP Request node below does the job.
</Note>

## With the HTTP Request node

<Steps>
  <Step title="Add an HTTP Request node">
    * **Method**: POST
    * **URL**: `https://api.branchpilot.ai/v1/decide/lead-routing` (your decision's slug)
    * **Authentication**: Generic → Header Auth, name `Authorization`, value `Bearer bp_live_…` (store it as an n8n credential)
    * **Send body**: JSON
  </Step>

  <Step title="Build the body">
    ```json theme={null}
    { "input": { "email": "{{ $json.email }}", "message": "{{ $json.message }}" } }
    ```
  </Step>

  <Step title="Branch on the answer">
    Add a **Switch** node on `{{ $json.choice }}` with one output per option and one for `__uncertain__`. For score decisions, use a Switch on number ranges of `{{ $json.score }}`; for classify decisions, an **IF** node per label with `{{ $json.labels.includes('billing') }}`.
  </Step>
</Steps>

<Tip>
  Set the HTTP Request node's timeout to at least 10 seconds and enable **Retry on fail** for `5xx` responses.
</Tip>
