Instagram bot with an AI agent: import the schema and test the answers
This guide shows how to connect an AI agent to an Instagram bot: you import a ready-made schema into MyCode.Bot, select your agent in the AI agent node and test the answers in Direct.
What you get
The bot keeps the menu with 🛍 Catalog, 🚚 Delivery and 📞 Call me back and adds 💬 Ask a question. Any message the customer types goes to the AI agent:
- if the agent finds the answer, the bot sends it with the 📞 Call me back and 🏠 Main menu buttons;
- if the agent needs a person or cannot answer, the bot offers to leave a phone number for a manager.
Before you start
- A bot with an Instagram token in panel.mycode.bot. See the Instagram bot without AI.
- An active AI agent with a knowledge base. See how to create an AI agent.
Download the schema
Download the schema (JSON, 30 KB)
The file uses the imaginary Demo Shop with English texts. It has no keys, customer data or agent: you select your own agent in step 2.
Step 1. Import the schema
- Open the schema of your bot on the Canvas.
- Press the import button on the bottom panel, choose the downloaded file and press Import.
The AI agent node has a red mark: no agent is selected yet.
Step 2. Select the agent
Open the AI agent node and select your agent. The other fields are already filled in:
| Field | Value | What it means |
|---|---|---|
| Message | #userInput | The text the customer typed. |
| Context | Customer name and channel | Lets the agent greet the customer by the name from the Instagram profile. |
| topic | products, sizes, delivery, payment, returns, order, other | The agent sets the topic of each message. |
After the agent comes the Manager needed? condition. It sends the customer to the Manager needed screen when the agent asks for a person or fails to answer, and to the AI answer screen in all other cases.
Step 3. Test the bot in Instagram
Write to your Instagram account in Direct from a different account and ask:
| Question | What the bot does |
|---|---|
| What sizes does the hoodie come in? | Answers from the knowledge base: S to XXL. |
| Do you ship to Canada? How long does it take? | Gives the delivery time and cost from the shop rules. |
| Where is my order #1234? | Says it cannot see orders and offers to call you back. |
| What’s the weather in London today? | Says it helps only with shop questions. |
The agent needs a few seconds to prepare each answer.
Step 4. Check usage and analytics
- The agent’s page shows how many messages it has used.
- Analytics lists every answer of the agent: whether it found an answer and whether a person is needed.
A new agent has a message limit
A new agent can send 50 messages. To raise the limit, write to support@smsbat.com.
Common questions
The AI agent node is red. Open the node and select your agent.
The bot says that something went wrong. Check that the agent is Active and has a provider token, and that it has not used up its message limit.
Where do I find the phone numbers customers leave? In Subscribers in MyCode.Bot. The bot saves the number to the customer’s profile.