Guides
All topics
erxes XOS
Sales
Settings
Account
Workspace
Developers
Core Modules
Broadcasts
Documents
Automations
Segments
Contacts
Plugins
Operation
Sales
Frontline
Tourism
Content
Accounting
Agents
Company Brain
Mongolian
Loyalty
AI Automation Creation Guide
AI Automation Creation Guide
A complete guide to creating an AI Agent with Kimi for Code in erxes, connecting Facebook/Instagram Messenger bots, and building an automation that sends automatic replies when messages arrive.
1
Create an AI Agent
First, create the AI Agent that will be used in the automation. This agent receives user messages and prepares replies based on predefined knowledge and responsibilities.
Step 1: Settings → Automations → Agents
- 1. Log in to the erxes system.
- 2. From the left menu, go to Settings → Automations.
- 3. Click the Agents tab.
- 4. In Provider, select Kimi for Code.
5. Click Create Agents or Create First Agent.
Go to Settings → Automations → Agents, select Kimi for Code, then click Create Agents.
Step 2: Enter General Information
Fill in Name and Description in the General tab.
| Field | Value | Example |
|---|---|---|
| Name | AI Agent name | Delgerekh |
| Description | Description | Delgerekh's AI agent |
Step 3: Connect Kimi Coding
In the Connection tab, configure Provider, Model, API key, Temperature, Max Tokens, and Timeout.
Connection Settings
- 1. Provider: Kimi Coding
- 2. Model: KIMI-FOR-CODING
- 3. API Key: Enter the API key purchased from Kimi Code
- 4. Base URL: https://api.kimi.com/coding
- 5. Temperature: 0.2
- 6. Max Tokens: 500
- 7. Timeout: 15000 ms
To get a Kimi Code API key, choose a paid plan at www.kimi.com/code.
Note: An API key is required to use Kimi Coding. If you don't have one, register on the official Kimi Code website and choose the appropriate plan to get an API key.
Step 4: Write the Context / System Prompt
In the Context tab, write the AI assistant's role and company information.
System Prompt Example
# You are Delgerekh's official AI assistant
## Your main responsibility
Receive customer questions, suggestions, requests, and complaints related to delivery, provide accurate information, and escalate to the relevant staff when necessary.
---
## About the company
[Write detailed company information, services, products, and contact details here
Step 5: Save the AI Agent
After filling in all the information, click Save. The created agent appears in the AI Agents list.
The Delgerekh agent appears in the AI Agents list.
2
Connect Messenger Bots
Before using the AI Agent in an automation, you need to connect Facebook Messenger and Instagram Messenger bots.
Step 1: Go to Automations → Bots
- 1. Go to Settings → Automations → Bots.
- 2. Facebook Messenger and Instagram Messenger bots are shown here.
The Automation bots section shows Facebook Messenger and Instagram Messenger.
Step 2: Connect Facebook Messenger Bot
Select the Facebook account.
Select the Facebook Page.
Configure the bot name (Delgerekh AI) and persistent menu.
Steps to Connect Facebook Messenger Bot
- 1. Click Add Bot on the Facebook Messenger card.
- 2. STEP 1: Select the Facebook account to connect (example: Bat-Erdene Bayartsogt).
- 3. STEP 2: Select the Facebook Page to connect (example: Mongol Tech Hub).
- 4. Enter the bot name (example: Delgerekh AI).
- 5. Add a Persistent menu if needed.
- 6. Click Save.
Step 3: Connect Instagram Messenger Bot
Select the Instagram account.
Select the Instagram Page.
Configure the Instagram bot name (Delgerekh Instagram AI) and Get Started menu.
Steps to Connect Instagram Messenger Bot
- 1. Click Add Bot on the Instagram Messenger card.
- 2. STEP 1: Select the Instagram account to connect (example: Bat-Erdene Bayartsogt).
- 3. STEP 2: Select the Instagram Page to connect (example: uu759204).
- 4. Enter the bot name (example: Delgerekh Instagram AI).
- 5. Configure Get Started or other persistent menus.
- 6. Click Save.
3
Create the Automation
Once the AI Agent and bots are ready, create an automation so the AI replies automatically when a user sends a message.
Step 1: Go to Automations and Create a New Automation
- 1. From the main left menu, go to Core modules → Automations.
- 2. Click Create a new automation.
- 3. Enter the automation name (example: delgerekh ai chatbot).
Core modules → Automations → Create a new automation.
Step 2: Configure the Trigger
Trigger type: Facebook Message, Bot: DELGEREKH AI, Event: Direct Message.
Trigger Configuration
- 1. In the workflow, click + Add trigger in the Start → Trigger section.
- 2. Select trigger type: Facebook Message.
- 3. Select bot: DELGEREKH AI.
- 4. Select event: Direct Message (when a user sends a direct message).
- 5. Click Save Configuration.
Step 3: Add the AI Agent Action
AI Agent action Configuration tab: AI Agent = Delgerekh, Goal Type = Generate Text.
AI Agent Action Configuration
- 1. After the trigger, click + to add an Action.
- 2. Select action type: AI Agent.
- 3. Configuration tab:
- -AI Agent: Delgerekh (the created agent)
- -Goal Type: Generate Text
- -AI Input: leave blank to send the entire trigger payload
- -Instruction Prompt: add extra instructions if needed
- -Fallback Response: message shown if the reply is delayed
Step 4: Configure AI Agent Memory
Memory tab: Read/Write namespace is {{ trigger.conversationId }}.
Memory Configuration
- 1. In the AI Agent action, open the Memory tab.
- 2. Read from memory: enabled
- 3. Read namespace: {{ trigger.conversationId }}
- 4. Save result to memory: enabled
- 5. Write namespace: {{ trigger.conversationId }}
- 6. Click Save Configuration.
Important: Using {{ trigger.conversationId }} allows each user to have their own conversation history stored. This lets the AI agent remember previous messages and provide better replies.
Step 5: Add the Send Facebook Message Action
In the Send Facebook Message action, set Text to {{prevAction.text}}.
Reply Action
- 1. After the AI Agent action, click + again to add another Action.
- 2. Select action type: Send Facebook Message.
- 3. Click Add Text in the message sequence.
- 4. In the Text field, enter: {{prevAction.text}}.
- 5. Click Save Configuration.
4
Save, Activate, and Verify the Automation
After configuring all triggers and actions, save and activate the automation.
Complete workflow: Trigger → AI Agent → Send Facebook Message.
- 1. Check the workflow
Trigger: Facebook Message → DELGEREKH AI → Direct Message; Action 1: AI Agent (Generate text, reads memory); Action 2: Send Facebook Message ({{prevAction.text}})
2. Save
Click the Save button in the top-right corner.
3. Activate
Toggle INACTIVE to active to switch the automation to active status.
The delgerekh ai chatbot automation appears as active in the Automations list.
| Name | VISIBILITY | STATUS | TRIGGERS | ACTIONS |
|---|---|---|---|---|
| delgerekh ai chatbot | Public | active | 1 | 2 |
Test the Automation
- 1. Send a test message from the Facebook Page Messenger.
- 2. If the automation is configured correctly, the AI agent's reply will arrive within a few seconds.
- 3. If no reply arrives, check the logs in Automation → History.
Troubleshooting:
- *Check that the AI Agent's API key is valid.
- *Check that the bot is connected correctly.
- *Check that the automation is active.
- *Check that Direct Message is selected in the trigger.
- *Check that {{prevAction.text}} is entered correctly in the Send Facebook Message action.