For the complete documentation index, see llms.txt. This page is also available as Markdown.
n8n Integration
This document provides detailed instructions on how to integrate multiple MaiAgent AI assistants using the n8n workflow automation tool. Through n8n, you can easily create workflows to achieve multi-assistant integration effects.
Prerequisites
Registered n8n account
Valid MaiAgent API key
Completed AI assistant setup with assistant ID
Basic understanding of APIs and workflows
Basic Concepts
MaiAgent API provides functionality to interact with AI assistants. We will use n8n to automate these processes and integrate multiple AI assistants.
Workflow Examples
Example 1: Creating a Simple AI Assistant Chain Workflow
This workflow will receive user chat messages and process them sequentially through two different AI assistants, forming a chained processing flow.
Step 1: Set Up Chat Trigger Node
Add a "When chat message received" node in the n8n workflow
This will serve as the workflow's starting point, triggered when users send messages
Step 2: Set Up First HTTP Request Node
Add an "HTTP Request" node, connected to the "When chat message received" node
Final aggregation assistant provides comprehensive recommendations
Scenario 2: Translation Improvement Process
Initial assistant performs translation
Secondary assistant checks translation quality
Final assistant polishes and optimizes expression
Scenario 3: Content Generation and Review Workflow
Creative assistant generates content
Review assistant checks accuracy and appropriateness
Editor assistant polishes and optimizes formatting
Advanced Application: Building Multi-Round Conversation Workflow
Example 2: Using Conversation ID for Multi-Round Dialogues
Step 1: Create Conversation Initialization Node
Add an HTTP Request node for initial conversation
Configure similar to previous settings, but store conversation ID:
Step 2: Set Up Subsequent Conversation Node
Add new HTTP Request node, configured to use saved conversation ID:
Troubleshooting
Common issues and solutions:
API Authentication Error: Ensure correct API key format, including "Api-Key" prefix
Request Timeout: Increase HTTP request node timeout for complex queries
Streaming Mode Handling: Use is_streaming: true to change response mode to streaming
Conclusion
Through n8n, you can easily integrate and automate multiple MaiAgent AI assistants, creating powerful AI workflows that enable different specialized assistants to collaborate on complex tasks. From simple conversations to complex multi-assistant chain processing, n8n provides flexible and powerful automation capabilities.
Appendix: Complete Workflow JSON
Below is the complete workflow JSON configuration for Example 1, which you can directly import into n8n:
// Store conversation ID for subsequent use
const conversationId = $json.conversationId;
$workflow.vars.conversationId = conversationId;
return {
json: {
...$json,
savedConversationId: conversationId
}
};
{
"conversation": "{{$workflow.vars.conversationId}}",
"message": {
"content": "Continue from the previous question, please provide more details"
},
"is_streaming": false
}