n8n Integration

This guide shows you how to add FlautoPsy monitoring to your n8n automation workflows.

Step 1: Get Your Webhook URL

  1. Log in to FlautoPsy at https://flautopsy.stralocroft.com/dashboard
  2. Go to Settings → Setup (or /setup)
  3. Copy your unique webhook URL

Step 2: Add an HTTP Request Node

  1. Open your n8n workflow
  2. Click + to add a new node
  3. Search for HTTP Request and select it
  4. Click Add node

Step 3: Configure the HTTP Request Node

In the HTTP Request node settings:

| Field | Value | |-------|-------| | Request Method | POST | | URL | Paste your FlautoPsy webhook URL | | Content-Type | application/json | | Headers | None required (n8n sets Content-Type automatically) |

Step 4: Set Request Body

Click on the Body tab and switch to JSON mode (if not already selected).

Paste the following JSON template:

json
{
"workflow_id": "your-workflow-name",
"prompt": "{{$node.PreviousNode.json.prompt}}",
"output": "{{$node.PreviousNode.json.output}}",
"latency_ms": {{$node.PreviousNode.json.latencyMs}},
"cost_tokens": {{$node.PreviousNode.json.costTokens}},
"model": "gpt-4"
}

Mapping n8n Variables

Replace the template variables with outputs from your LLM node:

| Field | n8n Variable | |-------|--------------| | workflow_id | A fixed string, e.g.,

text
"email-classifier"
| | prompt |
text
{{$node.YourLLMNode.json.prompt}}
(replace
text
YourLLMNode
with your node name) | | output |
text
{{$node.YourLLMNode.json.message}}
or similar (depends on your LLM provider) | | latency_ms |
text
{{$node.YourLLMNode.json.duration}}
or calculate manually | | cost_tokens |
text
{{add($node.YourLLMNode.json.usage.prompt_tokens, $node.YourLLMNode.json.usage.completion_tokens)}}
| | model | The model name as a string, e.g.,
text
"gpt-4"
|

Example with OpenAI Node

If your workflow includes an OpenAI Chat Model node named

text
OpenAI
:

json
{
"workflow_id": "email-classifier",
"prompt": "{{$node.OpenAI.json.messages[0].content}}",
"output": "{{$node.OpenAI.json.choices[0].message.content}}",
"latency_ms": 245,
"cost_tokens": {{add($node.OpenAI.json.usage.prompt_tokens, $node.OpenAI.json.usage.completion_tokens)}},
"model": "gpt-4"
}

Step 5: Test the Node

  1. Click Test step (play icon) to send a test request
  2. You should see a Success response with status 200
  3. Check FlautoPsy dashboard → Traces to confirm the trace arrived

Step 6: Activate the Workflow

  1. Run your workflow 10+ times to build a baseline
  2. Traces will be logged to FlautoPsy after each run
  3. Once mature (≥10 traces), drift alerts will trigger automatically

n8n-Specific Notes

  • Use
    text
    {{}}
    for variable substitution, not
    text
    ${}
    or other formats
  • The HTTP Request node automatically sets
    text
    Content-Type: application/json
  • Test individual nodes by clicking Test step
  • If your workflow has multiple branches, place the HTTP Request node after your LLM call

Common Issues

"Request failed: 401 Unauthorized"

  • Double-check your webhook URL is correct
  • Copy it again from FlautoPsy Settings → Setup
  • Ensure no typos in the workspace_id parameter

Variables Not Showing in Output

  • The LLM node must run before the HTTP Request node
  • Check that your LLM node actually outputs the fields you're trying to access
  • Use
    text
    Test step
    on the LLM node first to verify output format

Latency Not Recorded

  • n8n's execution time is available via
    text
    $execution.runData
    , but it may vary
  • You can hard-code a value (e.g.,
    text
    250
    ) for testing
  • Or calculate it manually:
    text
    {{(new Date()).getTime() - $node.YourLLMNode.json.startTime}}

Troubleshooting

Workflow runs but traces don't appear

  • Check that all 10 required fields are in the JSON body
  • Verify the HTTP Request node shows a 200 OK response
  • Check FlautoPsy dashboard → Traces tab (may take 5-10 seconds to appear)

How do I see what was sent?

  • Use the Output tab in the HTTP Request node to inspect the response
  • Or use n8n's Debug mode to see the full request/response

Next Steps