Connecting Your Flockx Agent to n8n: Technical Integration Guide

FlockX’s powerful AI agents can be extended beyond the platform through integration with Make.com. This guide walks you through the process of connecting your FlockX agent to Make.com, enabling automated workflows triggered by your agent’s intelligence.

Core API Connectivity

Prerequisites

Before connecting your agent to Make.com, you’ll need:

  1. Your FlockX API Token - how to get your api key
  2. Your Agent’s UUID - Your agent’s unique identifier (format: e151675f-2d7c-46ee-a2a1-d68529adcb3d). You can find this in the web url of your browser e.g. https://agents.flockx.io/workbench/agents?agentId=82eee21b-089c-4aa5-b9a0-923c61ae712g
  3. A Make.com account - Free or paid, depending on your automation needs

FlockX Agent API Endpoint

The primary endpoint for agent interaction is:

https://api.flockx.io/api/v1/agents/{agent-id}/prompt

This endpoint accepts POST requests and returns your agent’s response.

Required Headers

Every API request to FlockX requires these headers:

Authorization: Token your-api-token-here
X-Twin: your-agent-uuid-here
Content-Type: application/json

Request Body Structure

The basic request body is simple:

1{
2 "prompt": "Your instruction or query for the agent"
3}

Response Format

The API returns a JSON response containing your agent’s reply:

1{
2 "message": "Your agent's response based on its knowledge"
3}

Setting Up n8n Integration

Basic n8n Workflow Creation

  1. Access your n8n instance
  2. Create a new workflow
  3. Add a trigger node that will initiate your workflow

Common triggers include:

  • Webhook (for external system events)
  • Schedule (for time-based triggers)
  • App-specific triggers (Telegram, Slack, etc.)

Configuring the HTTP Request Node for FlockX

After your trigger node, add an HTTP Request node:

  1. Click the ”+” icon after your trigger node
  2. Search for and select “HTTP Request”
  3. Configure the HTTP Request node:
    • Method: POST
    • URL: https://api.flockx.io/api/v1/agents/{your-agent-id}/prompt
    • Authentication: None (handled in headers)
    • Headers:
      Authorization: Token {{$credentials.flockxToken}}
      X-Twin: {{$env.AGENT_UUID}}
      Content-Type: application/json
    • Body Content Type: JSON
    • Request Body:
      1{
      2 "prompt": "{{$json.message}}"
      3}

Setting Up Credentials in n8n

For better security, store your FlockX API token as a credential:

  1. Go to Settings > Credentials
  2. Click “Add Credential”
  3. Select “Generic API”
  4. Name it (e.g., “FlockX API”)
  5. Add your API token

Then store your agent UUID as an environment variable:

  1. Go to Settings > Variables
  2. Add a new variable named “AGENT_UUID”
  3. Set the value to your agent’s UUID

Processing the Agent’s Response

Add nodes after the HTTP Request to process and use your agent’s response:

  1. Function node: Extract or transform the response
  2. Action nodes: Send emails, update databases, trigger other systems

Example n8n Workflows

Workflow 1: Chat Platform Integration

Trigger: Telegram

  1. Telegram Trigger Node: Listens for incoming messages
  2. Function Node: Prepares the prompt
    1const incomingMessage = $input.item.json.message.text;
    2const userName = $input.item.json.message.from.first_name;
    3
    4return {
    5 json: {
    6 message: `User ${userName} sent: "${incomingMessage}". Provide a helpful response.`
    7 }
    8};
  3. HTTP Request Node: Sends to FlockX API
  4. Function Node: Extracts agent response
    1return {
    2 json: {
    3 response: $input.item.json.message
    4 }
    5};
  5. Telegram Node: Sends response back to user

Workflow 2: Scheduled Content Creation

Trigger: Schedule (Daily)

  1. Schedule Node: Triggers at specific time
  2. HTTP Request Node (External API): Fetches trending topics
  3. Function Node: Formats data for agent
    1const trends = $input.item.json.trends.slice(0, 5).join(", ");
    2const date = new Date().toISOString().split('T')[0];
    3
    4return {
    5 json: {
    6 message: `Create a social media post about ${trends} for ${date}. Make it engaging and include relevant hashtags. Keep it under 280 characters.`
    7 }
    8};
  4. HTTP Request Node: Sends to FlockX agent
  5. Function Node: Processes agent’s content
  6. Twitter/LinkedIn/Facebook Node: Posts content to social media

Advanced n8n Integration Techniques

Multi-Step Conversation Management

Create a state-aware conversation flow using n8n’s data storage:

  1. Initial Trigger: Receives message
  2. Function Node: Get conversation history
    1// Get conversation ID or create new one
    2const conversationId = $input.item.json.conversationId || `conv_${Date.now()}`;
    3
    4// Retrieve history from n8n binary data or external database
    5const history = await $node.getWorkflowStaticData('global').conversations?.[conversationId] || [];
    6
    7return {
    8 json: {
    9 conversationId,
    10 history,
    11 newMessage: $input.item.json.message
    12 }
    13};
  3. Function Node: Build context with history
    1const history = $input.item.json.history.join("\n");
    2const newMessage = $input.item.json.newMessage;
    3
    4return {
    5 json: {
    6 message: `Previous conversation:\n${history}\n\nNew message: ${newMessage}\n\nRespond to this latest message with full context.`,
    7 conversationId: $input.item.json.conversationId
    8 }
    9};
  4. HTTP Request Node: Sends to FlockX agent
  5. Function Node: Update conversation history
    1const conversations = $node.getWorkflowStaticData('global').conversations || {};
    2const conversationId = $input.item.json.conversationId;
    3
    4// Get existing history or initialize
    5const history = conversations[conversationId] || [];
    6
    7// Add new message and response
    8history.push(`User: ${$input.item.json.newMessage}`);
    9history.push(`Agent: ${$input.item.json.message}`);
    10
    11// Keep only last 10 messages
    12if (history.length > 10) {
    13 history.splice(0, history.length - 10);
    14}
    15
    16// Update stored history
    17conversations[conversationId] = history;
    18$node.getWorkflowStaticData('global').conversations = conversations;
    19
    20return {
    21 json: {
    22 response: $input.item.json.message,
    23 conversationId
    24 }
    25};
  6. Response Node: Send agent response back

Data Enrichment Before Agent Queries

Use n8n to gather and structure information before querying your agent:

  1. Trigger Node: Initiates workflow
  2. HTTP Request Nodes (Multiple): Gather data from various sources
    • CRM data
    • Weather information
    • Stock prices
    • Calendar events
  3. Function Node: Structure data for agent
    1const customerData = $input.item.json.customerData;
    2const weatherData = $input.item.json.weatherData;
    3const marketData = $input.item.json.marketData;
    4const events = $input.item.json.events;
    5
    6return {
    7 json: {
    8 message: `
    9 Generate a personalized briefing for ${customerData.name}.
    10
    11 Customer details:
    12 - Account type: ${customerData.accountType}
    13 - Preferences: ${customerData.preferences.join(", ")}
    14
    15 Today's weather: ${weatherData.condition}, ${weatherData.temperature}°C
    16
    17 Market update:
    18 ${marketData.highlights.join("\n")}
    19
    20 Upcoming events:
    21 ${events.map(e => `- ${e.date}: ${e.title}`).join("\n")}
    22
    23 Create a brief, personalized update that highlights relevant information.
    24 `
    25 }
    26};
  4. HTTP Request Node: Sends enriched data to FlockX agent
  5. Action Nodes: Deliver the personalized briefing

Best Practices for n8n Integration

Security

  • Use n8n credentials to store sensitive information
  • Leverage environment variables for configuration
  • Implement error handling for API failures

Performance

  • Use the “Split In Batches” node for processing large datasets
  • Implement caching where appropriate
  • Consider execution limits based on your n8n setup

Workflow Design

  • Create modular workflows that can be reused
  • Use error handling nodes to manage exceptions
  • Document your workflows with notes

Prompt Engineering

  • Structure prompts consistently
  • Include all necessary context in each prompt
  • Use Function nodes to dynamically build complex prompts

Troubleshooting Common Issues

IssuePossible Solution
Authentication failuresVerify credentials are correctly set up
Data formatting errorsUse Function nodes to sanitize input data
Workflow execution timeoutsBreak complex workflows into smaller ones
Rate limitingImplement “Wait” nodes between API calls
Inconsistent agent responsesReview and refine your prompt structure

Next Steps

After implementing your basic integration, consider these advanced capabilities:

  1. Create a central agent management workflow: Coordinate multiple agents for different tasks
  2. Implement feedback loops: Track agent performance and automate improvements
  3. Build hybrid workflows: Combine automated and human-in-the-loop processes
  4. Develop custom n8n nodes: Create reusable FlockX integration components

By connecting your FlockX agent to n8n, you’ll create powerful automation workflows that extend your agent’s capabilities across your entire business ecosystem while maintaining full control over your integration architecture.