n8n Integration
Overview
n8n is a powerful open-source automation platform that allows users to create, deploy, and manage complex workflows through a visual interface. It supports integration with over 300 applications and services, and provides multiple trigger methods such as webhook and scheduled triggers.
The bidirectional integration between OneAI and n8n offers users robust automation capabilities:
- OneAI calls n8n workflows: Through the skill plugin mechanism, n8n workflows can be used as OneAI extensions, enabling AI to trigger and execute complex automation processes for data processing, system integration, and more.
- n8n calls OneAI API: Seamlessly invoke OneAI's intelligent services within n8n workflows, injecting AI capabilities into automation processes, such as text analysis, content generation, knowledge Q&A, etc.
This bidirectional integration provides enterprises with flexible automation solutions, applicable to scenarios such as customer service automation, data processing workflows, cross-system business process orchestration, intelligent notifications, and more, helping organizations improve operational efficiency and reduce manual costs.
n8n Calls OneAI API
Install OneAI Community Node
Go to the settings page via the n8n workspace bottom left ... > Setting, and install n8n-nodes-oneai in Community nodes:

Please restart the n8n service after installing the community node, otherwise you may see duplicate OneAI nodes in the node panel.
Add OneAI Credential
In the credential addition interface, select OneAI.

Fill in the following information:
- Base URL: OneAI server address, without trailing
/ - Client ID: Create and obtain via OneAI Client Management
- Client Secret: Create and obtain via OneAI Client Management
- User Account: Corresponding User Name in user management; API calls will be made as this user, please ensure the user has sufficient API permissions
After saving, the credential will be automatically tested. If configured correctly, it will display Connection tested successfully:

Method 1: Call OpenAPI via One AI Node
Select the One AI node:

Select the Action to execute:

Test the node:
- Configure with appropriate parameters
- Click the "Test Step" button to execute the test
- View the execution result in the right panel

Specific testing steps:
- Ensure the correct OneAI Credential is selected
- Fill in the required input parameters
- Execute the node and verify if the returned result meets expectations
- If execution fails, check the error message and adjust the configuration accordingly
Method 2: Call OpenAPI via HTTP Request Node
Currently, the OneAI Node only provides some OpenAPI Operations. If the required API is not in the OneAI Node's Operation list, you can use the HTTP Request Node to call the API directly.
Select the HTTP Request node:

Configure request parameters:
- Method: Select the appropriate HTTP method (GET/POST/PUT, etc.)
- URL: Enter the full OneAI API URL path
- Headers: Add request headers as needed
- Query Parameters/Body: Configure according to API requirements
You can import via cURL, but be sure to remove Authorization from the Header, otherwise it will conflict with the Authentication configuration below.
Configure Authentication:
- Authentication: Select Predefined Credential Type
- Credential Type: Choose OneAI API
- OneAI API: Select an existing OneAI Credential or create a new one

Test the node:
- Confirm all parameter configurations are correct
- Click the "Execute Node" button to run the test
- Check if the returned result meets expectations

OneAI Calls n8n Workflow
Create n8n Workflow
First, create a workflow named Echo and set the Trigger to Webhook. After creation, click the "Active" button in the upper right to activate the workflow.

Configure the Webhook:
- HTTP Method: Select POST
- Path: The address to call this workflow, you can use the default value
- Authentication: Select
Header Authand create a Credential; save the Header and Value for later skill plugin configuration - Respond: Select
Using 'Respond to Webhook' Node

Add a Respond to Webhook node and configure as follows:
- Respond With: Select JSON
- Response Body: Switch Fixed to Expression and enter the following json:
{
"output": "{{ $json.body.input }}"
}

Add Skill and Link to n8n Workflow
Complete the following configuration in the OneAI platform:
- Code: Enter echo
- Name: Enter echo, click the magic wand for auto-translation
- Description: Enter echo, click the magic wand for auto-translation
- Request header: If Header Auth was set in the previous n8n webhook, add the corresponding Header and Value here to ensure API authentication passes
- OpenAPI / Swagger Schema (JSON): Modify based on the following template:
Replace {n8n_server_url} with the n8n server URL, and {n8n_webhook_path} with the n8n webhook node path
{
"openapi": "3.0.3",
"info": {
"title": "N8N echo example",
"version": "1.0.0"
},
"servers": [
{
"url": "{n8n_server_url}"
}
],
"paths": {
"/webhook/{n8n_webhook_path}": {
"post": {
"operationId": "echo",
"summary": "echo",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"input": {
"type": "string",
"description": "Text content from user input"
}
},
"required": [
"input"
]
}
}
}
},
"responses": {
"200": {
"description": "Echo success",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"output": {
"type": "string",
"description": "Echo output"
}
},
"required": [
"output"
]
}
}
}
}
}
}
}
}
}

After setup, you can click the "debug" button to test:

Call Skill via Agent
Add the echo skill to the Agent:

Modify the Agent's Prompt to guide skill invocation.
Prompt example:
# Skill echo
If the user enters the `echo` command, please call the `echo` function and return `output` in the result.
Test the skill (input echo 1+1=?, return 1+1=?, and you can see the echo skill was called):

Check n8n workflow execution status:

More complex workflows can be extended based on this example.
For example: If you need to query a database via n8n and return data, you can add a Database node between the Webhook and Respond to Webhook nodes and configure the database connection information. Then adjust the Respond to Webhook Body value accordingly to correctly return the queried data.
Best Practices & Troubleshooting
Best Practices
- Write clear comments and descriptions for each workflow
- Use appropriate error handling mechanisms to ensure workflow stability
- Regularly check workflow execution history and logs
- For complex workflows, it is recommended to validate in a test environment first
Common Issue Troubleshooting
-
Authentication Failure
- Check if Credential configuration is correct
- Confirm if Client ID and Secret are valid
- Verify if the user account has sufficient permissions
-
Webhook Call Failure
- Confirm n8n service is accessible from the OneAI server
- Check if authentication header information is correctly configured
- Verify if the webhook path is correct
-
Node Execution Error
- Check if input data format meets requirements
- Confirm API version compatibility
- View detailed error log information
Deploy n8n
n8n provides deployment documentation for various environments. You can refer to n8n self-hosted deployment to choose the most suitable deployment method for you.
If you want to quickly deploy n8n on the Azure platform and are familiar with Terraform, the following script is for your reference:
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "4.27.0"
}
}
}
provider "azurerm" {
features {}
subscription_id = var.subscription_id
tenant_id = var.tenant_id
}
# Variable definitions
variable "subscription_id" {
description = "Azure Subscription ID"
type = string
default = "your-subscription-id"
}
variable "tenant_id" {
description = "Azure Tenant ID"
type = string
default = "your-tenant-id"
}
variable "application_name" {
description = "Application name"
type = string
default = "n8n"
}
variable "environment" {
description = "Environment"
type = string
default = "dev"
}
variable "location" {
description = "Azure region"
type = string
default = "eastasia"
}
variable "container_image" {
description = "N8N container image"
type = string
default = "n8nio/n8n:latest"
}
variable "n8n_host" {
description = "N8N URL"
type = string
default = "your-app-url.azurewebsites.net"
}
variable "random_suffix" {
description = "Random string"
type = string
default = "suffix"
}
variable "app_service_sku" {
description = "App Service Plan SKU"
type = string
default = "B2"
}
# Account and password variables
variable "n8n_encryption_key" {
description = "N8N encryption key"
type = string
default = "your-encryption-key"
sensitive = true
}
variable "n8n_basic_auth_user" {
description = "N8N basic auth username"
type = string
default = "admin"
}
variable "n8n_basic_auth_password" {
description = "N8N basic auth password"
type = string
default = "your-secure-password"
sensitive = true
}
variable "postgresql_admin_username" {
description = "PostgreSQL admin username"
type = string
default = "psqladmin"
}
variable "postgresql_admin_password" {
description = "PostgreSQL admin password"
type = string
default = "your-secure-password"
sensitive = true
}
# Resource Group
resource "azurerm_resource_group" "n8n" {
name = "rg-${var.application_name}-${var.environment}"
location = var.location
}
# App Service Plan
resource "azurerm_service_plan" "n8n" {
name = "asp-${var.application_name}-${var.environment}"
resource_group_name = azurerm_resource_group.n8n.name
location = azurerm_resource_group.n8n.location
os_type = "Linux"
sku_name = var.app_service_sku
}
# App Service (Web App for Containers)
resource "azurerm_linux_web_app" "n8n" {
name = "app-${var.application_name}-${var.environment}-${var.random_suffix}"
resource_group_name = azurerm_resource_group.n8n.name
location = azurerm_resource_group.n8n.location
service_plan_id = azurerm_service_plan.n8n.id
app_settings = {
"N8N_ENCRYPTION_KEY" = var.n8n_encryption_key
"N8N_HOST" = "${var.n8n_host}"
"N8N_PORT" = "443"
"N8N_PROTOCOL" = "https"
"N8N_WEBHOOK_URL" = "https://${var.n8n_host}/"
"GENERIC_TIMEZONE" = "Asia/Shanghai"
"N8N_BASIC_AUTH_ACTIVE" = "true"
"N8N_BASIC_AUTH_USER" = var.n8n_basic_auth_user
"N8N_BASIC_AUTH_PASSWORD" = var.n8n_basic_auth_password
"EXECUTIONS_DATA_PRUNE" = "true"
"EXECUTIONS_DATA_MAX_AGE" = "336"
"WEBSITES_PORT" = "443"
# DB Config
"DB_TYPE" = "postgresdb"
"DB_POSTGRESDB_HOST" = "${azurerm_postgresql_flexible_server.postgresql_server.fqdn}"
"DB_POSTGRESDB_PORT" = "5432"
"DB_POSTGRESDB_DATABASE" = "${azurerm_postgresql_flexible_server_database.postgresql_database.name}"
"DB_POSTGRESDB_USER" = var.postgresql_admin_username
"DB_POSTGRESDB_PASSWORD" = var.postgresql_admin_password
"DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED" = "false"
}
site_config {
always_on = true
websockets_enabled = true
application_stack {
docker_image_name = "${var.container_image}"
docker_registry_url = "https://docker.n8n.io"
}
}
}
# PostgreSQL database server
resource "azurerm_postgresql_flexible_server" "postgresql_server" {
name = "psql-${var.application_name}-${var.environment}"
resource_group_name = azurerm_resource_group.n8n.name
location = azurerm_resource_group.n8n.location
administrator_login = var.postgresql_admin_username
administrator_password = var.postgresql_admin_password
version = "16"
sku_name = "B_Standard_B1ms"
# 128GB
storage_mb = 131072
backup_retention_days = 35
geo_redundant_backup_enabled = true
public_network_access_enabled = true
lifecycle {
ignore_changes = [
zone,
]
}
}
# PostgreSQL firewall rule
resource "azurerm_postgresql_flexible_server_firewall_rule" "postgresql_firewall_rule" {
name = "AllowAzureServicesAccessPGSQL"
server_id = azurerm_postgresql_flexible_server.postgresql_server.id
start_ip_address = "0.0.0.0"
end_ip_address = "0.0.0.0"
}
# PostgreSQL database instance
resource "azurerm_postgresql_flexible_server_database" "postgresql_database" {
name = "psqldb-${var.application_name}-${var.environment}"
server_id = azurerm_postgresql_flexible_server.postgresql_server.id
charset = "UTF8"
collation = "en_US.utf8"
}
# Output
output "n8n_url" {
description = "N8N access url"
value = "https://${azurerm_linux_web_app.n8n.default_hostname}"
}
References
n8n Related Resources
- n8n Official Documentation
- n8n Webhook Node Documentation
- n8n HTTP Request Node Documentation
- n8n Community Forum