n8n workflows
AI-Public can start n8n workflows via a production webhook. This is useful when you want to trigger an automated process outside AI-Public, for example creating a task, updating a CRM record, starting a reporting flow, or forwarding form data to another system.
Example: news article on the organization’s website
Suppose the organization has created an n8n workflow that publishes a news article on the WordPress website. In AI-Public, you then only enter a short piece of text, for example a few sentences about a meeting, project, or public announcement. That text is used to start the workflow in n8n.
The n8n workflow can then, for example:
- Turn the short text into a polished draft using an LLM node and a prompt that fits the organization’s tone.
- Generate a suitable illustration with a second LLM node, for example in the brand colors and in a recognizable illustrative style.
- Prepare or publish the text and image as a blog post on the WordPress website.
This is how AI-Public and n8n work together: in AI-Public, the user selects the workflow and enters the required information. n8n then performs the automated steps and ensures the news article ends up neatly on the website.
What does this integration do?
You start an n8n workflow from the workflow overview. Only the production webhook, POST, and Header Auth are required. Fields and callbacks from n8n are optional and can be configured independently.
- If the workflow has no fields, the webhook is called immediately.
- If the workflow does have fields, a form opens first. The user fills in the fields and then starts the workflow with the button.
- The entered values are sent as JSON in a POST request to the n8n webhook.
- Without callbacks, AI-Public only confirms that the workflow has started and continues running in n8n. The window does not show a spinner and can be closed immediately.
- If enabled during registration, the workflow can send intermediate steps or the end state back to AI-Public.
- If approval is enabled during registration, the user can make a choice directly in AI-Public. n8n then continues from the waiting step.
Creating an n8n workflow in AI-Public
An administrator registers the workflow as follows:
- Go to Assistants.
- Open the Workflow assistants tab.
- In the card at the top, click New workflow and choose n8n workflow.
- Enter the workflow name and the n8n production URL.
- Set Header authentication with a header name and secret header value.
- Under Callbacks from n8n, only check the parts that are actually built into this n8n workflow: progress, approval, and/or workflow completion.
- Optionally add the fields that should be sent in the POST request.
- Save the workflow.
All three callback options are off by default. If you later add callbacks or an approval step in n8n, update the registration in AI-Public as well. This tells the dialog whether it should only show a start confirmation or keep waiting for further signals.
Fields
- Fields are optional.
- Each field has one field name and a type.
- Supported field types are short text, long text, number, yes/no, date, single choice, and multiple choices.
- For Single choice and Multiple choices, add the available options. Single choice is shown as a compact selection list; Multiple choices shows checkboxes. The selected value or values are sent in the JSON body.
- Required fields must be filled in before the workflow can be started.
- The field name becomes the key in the JSON body sent to n8n.
Creating a compatible workflow in n8n
- Create a new workflow in n8n.
- Add a Webhook node as the first node.
- Name this node exactly Start workflow. The example expressions below use this name.
- Set HTTP Method to POST.
- Choose Authentication: Header Auth and use the same header name and secret value as in AI-Public.
- Set Respond or Response Mode to Immediately.
- Copy the Production URL to the n8n production URL field in AI-Public. Do not use the test URL with
/webhook-test/. - Activate the workflow.
The received data is under body; the technical integration data is under body.integration. Do not remove it in an Edit Fields, Set, or Code node.
Example of the JSON body
If you define fields with the names prompt, customerName, audiences, and date, n8n receives for example this JSON body. AI-Public automatically adds the integration object.
{
"prompt": "Create a short summary of the request.",
"customerName": "Example organization",
"audiences": ["residents", "employees"],
"date": "2026-09-22",
"integration": {
"runId": "chat-document-id",
"tenant": "default",
"callbackUrl": "https://europe-west1-ai-public-pro.cloudfunctions.net/n8nWorkflowCallback",
"callbackToken": "temporary-token-for-this-execution"
}
}
The callback token belongs to one execution. Do not store it in logs, fixed configuration, or other systems.
Optional: send progress and completion back
AI-Public can only display what n8n sends back. Use these callbacks only if you enabled Report intermediate progress and/or Report the end of the workflow during registration.
Configure each callback node as follows:
-
Choose Method: POST.
-
Click Expression for URL and paste:
{{ $('Start workflow').first().json.body.integration.callbackUrl }} -
Choose Authentication: None.
-
Turn on Send Headers and add the headers below.
-
Turn on Send Body and choose Body Content Type: JSON and Specify Body: Using JSON.
Use these headers:
Authorization: Bearer {{ $('Start workflow').first().json.body.integration.callbackToken }}
Content-Type: application/json
For example, send this message when a step starts:
{
"tenant": "{{ $('Start workflow').first().json.body.integration.tenant }}",
"runId": "{{ $('Start workflow').first().json.body.integration.runId }}",
"eventId": "document-creation-started",
"type": "progress",
"executionId": "{{ $execution.id }}",
"step": {
"id": "document_creation",
"label": "Create document"
},
"message": "The document is being created."
}
- Use a unique
eventIdfor each event within the same execution. - Use a clear Dutch
step.label; this text is shown in the app. - If you enabled Report the end of the workflow, always send
type: "completed",type: "failed"ortype: "rejected"at the end. - For
completed, you can optionally add anoutputobject with the result. - For
failed, include a clear error message. The execution then also stops in the app.
Optional: request approval in the app
Use an n8n Wait node with On Webhook Call when the workflow may continue only after a choice. Send a callback with type: "approval_required" before the Wait node:
Configure the Wait node to Resume: On Webhook Call, HTTP Method: POST, and Authentication: Header Auth. Select the same Header Auth credential as for Start workflow. Add a Switch node after the Wait node and check {{ $json.body.decision }} there.
{
"tenant": "{{ $('Start workflow').first().json.body.integration.tenant }}",
"runId": "{{ $('Start workflow').first().json.body.integration.runId }}",
"eventId": "document-review",
"type": "approval_required",
"executionId": "{{ $execution.id }}",
"step": {
"id": "document_review",
"label": "Review document"
},
"approval": {
"question": "May the workflow continue?",
"context": "First review the generated document.",
"resumeUrl": "{{ $execution.resumeUrl }}",
"choices": [
{ "value": "approve", "label": "Approve" },
{ "value": "reject", "label": "Reject" }
]
}
}
The user sees the choices in the execution window. After a choice, the Wait node receives, among other things, decision. Then use for example a Switch node to determine the correct next step.
A choice value may contain only letters, numbers, _, and -. The label may contain normal readable text.
Setting the production callback URL
The production callback URL for AI-Public is:
https://europe-west1-ai-public-pro.cloudfunctions.net/n8nWorkflowCallback
Do not paste this URL as fixed text into every callback node. In the URL field of the HTTP Request node, choose Expression and use:
{{ $('Start workflow').first().json.body.integration.callbackUrl }}
This way, AI-Public automatically provides the correct production URL each time a workflow is started. Use the fixed URL above during testing to verify that the expression points to AI-Public and not to AI-School or AI-Corporate.
The callables triggerCustomN8nWorkflow, triggerN8nWorkflow, and resumeN8nWorkflow are called by the app itself. You do not need to set these URLs in n8n.
Handling errors
Return expected errors with a callback of type failed. For unexpected node errors, also create a central Error Workflow:
-
Create a new workflow with an Error Trigger node.
-
Then add an HTTP Request node with Method: POST.
-
In URL, enter this fixed production URL:
https://europe-west1-ai-public-pro.cloudfunctions.net/n8nWorkflowExecutionFailed -
Choose Authentication: None and add the header
n8n-handihow-namewith the platform administrator’s secret default value. -
Choose a JSON body and paste:
{
"executionId": "{{ $json.execution.id }}",
"workflowId": "{{ $json.workflow.id }}",
"workflowName": "{{ $json.workflow.name }}",
"lastNode": "{{ $json.execution.lastNodeExecuted }}",
"message": "{{ $json.execution.error.message }}"
}
- Activate the Error Workflow.
- Open the settings of the regular workflow and select this under Error Workflow.
Immediately after Start workflow, send at least one callback with executionId: "{{ $execution.id }}". Only then can AI-Public link an unexpected error to the correct execution.
Important limitations
- Only webhook triggers are supported.
- Only production webhook URLs are supported.
- Test webhook URLs with
/webhook-test/are rejected. - Only POST is supported.
- Only generic header authentication is supported.
- The header value is treated as secret in the application.
- Callback tokens and resume URLs are processed only server-side and are not directly available to users.
- The tenant is determined server-side from the logged-in user, not from a value sent by the browser.
Troubleshooting
- 404 or webhook not registered: activate the workflow in n8n and use the production URL.
- Authentication error: check that the header name and value are exactly the same in both systems.
- Missing data: check whether the field names in the application match the keys n8n expects.
- No request in n8n: check whether the workflow starts with a webhook trigger and uses POST.
- The execution window keeps running: if you enabled Report the end of the workflow, check whether n8n sends a final
completed,failed, orrejectedcallback. If you do not expect callbacks, turn off all three options in the registration. - No progress visible: check whether Report intermediate progress is enabled in the registration, whether the
integrationobject is preserved, and whether each callback has a uniqueeventId. - Approval buttons do not work: check the Wait node,
resumeUrl, header authentication, and the allowed characters inchoices[].value.