# AI Automation Creation Guide

Published 2026-09-22

> 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 arriv

## **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.  1\. Log in to the erxes system.
2.  2\. From the left menu, go to **Settings** → **Automations**.
3.  3\. Click the **Agents** tab.
4.  4\. In Provider, select **Kimi for Code**.
5.  5\. Click **Create Agents** or **Create First Agent**.  
     
    
    ![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/d17efdf2-c96e-4b55-912c-b3b7e978eb00/public)
    
    Go to Settings → Automations → Agents, select Kimi for Code, then click Create Agents.
    

### **Step 2: Enter General Information**

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/c27bbd8e-b99c-4420-0ed0-73c3af905000/public)

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**

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/3dd8cabb-b7b7-47b3-b694-34aa45115200/public)

In the Connection tab, configure Provider, Model, API key, Temperature, Max Tokens, and Timeout.

### **Connection Settings**

1.  **1\. Provider:** Kimi Coding
2.  **2\. Model:** KIMI-FOR-CODING
3.  **3\. API Key:** Enter the API key purchased from Kimi Code
4.  **4\. Base URL:** https://api.kimi.com/coding
5.  **5\. Temperature:** 0.2
6.  **6\. Max Tokens:** 500
7.  **7\. Timeout:** 15000 ms

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/447d1a27-782c-44e4-5b10-95f25219cb00/public)

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**

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/524b9463-3b63-4a6a-c51a-c875534c3000/public)

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.

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/811c7fa2-cd24-4aa4-44e6-575d005f2c00/public)

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.  1\. Go to **Settings** → **Automations** → **Bots**.
2.  2\. Facebook Messenger and Instagram Messenger bots are shown here.
3.  ![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/4ccd2975-c133-454f-ff77-4ab5be81fb00/public)
    

The Automation bots section shows Facebook Messenger and Instagram Messenger.

1.  ### **Step 2: Connect Facebook Messenger Bot**
    
2.  ![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/9cc3550b-3fde-4835-ba0b-28e329a99b00/public)
    

Select the Facebook account.

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/517e9063-32e1-478a-44dd-8314e69ddd00/public)

Select the Facebook Page.

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/1121b6d3-56e0-4fbb-5d5b-3ca3f3f0e900/public)

Configure the bot name (Delgerekh AI) and persistent menu.  
 

### **Steps to Connect Facebook Messenger Bot**

1.  **1\. Click Add Bot on the Facebook Messenger card.**
2.  **2\. STEP 1: Select the Facebook account to connect (example: Bat-Erdene Bayartsogt).**
3.  **3\. STEP 2: Select the Facebook Page to connect (example: Mongol Tech Hub).**
4.  **4\. Enter the bot name (example: Delgerekh AI).**
5.  **5\. Add a Persistent menu if needed.**
6.  **6\. Click Save.**

### **Step 3: Connect Instagram Messenger Bot**

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/392066ce-9569-4355-e265-b4dd50335000/public)

Select the Instagram account.

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/5d48c4b7-6d6c-4e79-f862-3dd204e32600/public)

Select the Instagram Page.

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/98f807ce-75ff-48be-e104-7c8e637d5d00/public)

Configure the Instagram bot name (Delgerekh Instagram AI) and Get Started menu.

### **Steps to Connect Instagram Messenger Bot**

1.  **1\. Click Add Bot on the Instagram Messenger card.**
2.  **2\. STEP 1: Select the Instagram account to connect (example: Bat-Erdene Bayartsogt).**
3.  **3\. STEP 2: Select the Instagram Page to connect (example: uu759204).**
4.  **4\. Enter the bot name (example: Delgerekh Instagram AI).**
5.  **5\. Configure Get Started or other persistent menus.**
6.  **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.  1\. From the main left menu, go to **Core modules** → **Automations**.
2.  2\. Click **Create a new automation**.
3.  3\. Enter the automation name (example: delgerekh ai chatbot).
4.  ![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/e71a5e09-75ee-43d7-d3ad-579a0cbd9c00/public)
    

Core modules → Automations → Create a new automation.

1.  ### **Step 2: Configure the Trigger**
    
2.  ![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/69b484d4-0cc2-49f6-85f2-c1acbef1dd00/public)
    

Trigger type: Facebook Message, Bot: DELGEREKH AI, Event: Direct Message.

1.  ### **Trigger Configuration**
    
2.  **1\. In the workflow, click + Add trigger in the Start → Trigger section.**
3.  **2\. Select trigger type: Facebook Message.**
4.  **3\. Select bot: DELGEREKH AI.**
5.  **4\. Select event: Direct Message (when a user sends a direct message).**
6.  **5\. Click Save Configuration.**

  
**Step 3: Add the AI Agent Action**

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/de62df2d-e40d-4bee-bc9b-b2f6c117ac00/public)

AI Agent action Configuration tab: AI Agent = Delgerekh, Goal Type = Generate Text.

### **AI Agent Action Configuration**

1.  **1\. After the trigger, click + to add an Action.**
2.  **2\. Select action type: AI Agent.**
3.  **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**

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/be538c61-054f-4c14-b878-1d1d0516c500/public)

Memory tab: Read/Write namespace is {{ trigger.conversationId }}.

### **Memory Configuration**

1.  **1\. In the AI Agent action, open the Memory tab.**
2.  **2\. Read from memory: enabled**
3.  **3\. Read namespace: {{ trigger.conversationId }}**
4.  **4\. Save result to memory: enabled**
5.  **5\. Write namespace: {{ trigger.conversationId }}**
6.   **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**

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/263ab860-0a92-4b49-bb26-8ee819c26500/public)

In the Send Facebook Message action, set Text to {{prevAction.text}}.

### **Reply Action**

1.  1\. After the AI Agent action, click **+** again to add another Action.
2.  2\. Select action type: **Send Facebook Message**.
3.  3\. Click **Add Text** in the message sequence.
4.  4\. In the Text field, enter: {{prevAction.text}}.
5.  5\. Click **Save Configuration**.

**4**

## **Save, Activate, and Verify the Automation**

After configuring all triggers and actions, save and activate the automation.

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/a34814ea-bbbd-4526-1547-781e4b3b2200/public)

Complete workflow: Trigger → AI Agent → Send Facebook Message.

1.  **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.

![](https://imagedelivery.net/5m26Aj-CutMXPPNacMs_yQ/f1e506c1-0395-4908-fef6-87fc04081b00/public)

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.  1\. Send a test message from the Facebook Page Messenger.
2.  2\. If the automation is configured correctly, the AI agent's reply will arrive within a few seconds.
3.  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.
