Help Center Create an AI agent with a knowledge base for your Instagram bot

Create an AI agent with a knowledge base for your Instagram bot

This guide shows how to create an AI agent in MyCode.Bot: you set its instructions, add an OpenAI key, upload a knowledge base and check the answers in the test chat. The example uses an imaginary Demo Shop, and you can download its files below.

What you get

An agent that answers questions about your business from your own files. It does not invent prices or dates, and it hands order questions and complaints over to a manager.

Creating the agent does not connect it to Instagram yet. Customers start getting its answers after you add the agent to a bot schema with the AI agent node.

Before you start

  1. Sign in to panel.mycode.bot.
  2. Get an OpenAI API key. Requests go through your key, so OpenAI bills you for them.
  3. If you do not have a bot yet, start with the Instagram bot without AI.

Download the demo files

The files describe an imaginary shop in English. They contain no keys or customer data.

Step 1. Create the agent

Open AI agents, press Create agent and fill in the basic settings:

FieldValue
Agent nameAny name, for example Test shop agent.
ModelAny available model. A small, fast one is enough for this demo.
ProviderOpenAI
Knowledge modeStrict: the agent answers only from your knowledge base.
Languageen
Tonefriendly_short
Maximum results5

Step 2. Fill in the instructions

Copy these texts into the form, then press Create.

Role prompt says who the agent is and how it behaves:

You are the online assistant of Demo Shop, a small clothing store that sells everyday clothes made from organic cotton. You talk to customers in Instagram Direct. Help them choose products and sizes, and answer questions about prices, delivery, payment, returns and exchanges. Use only the facts from the knowledge base about the shop.

Business rules set the limits of its answers:

- Keep every answer under 600 characters. Instagram cuts messages longer than 1000 characters.
- Write plain text without Markdown: no **bold**, no headings, no tables. Use short lines and emoji instead of lists when it helps.
- Answer in the language of the customer. If you are not sure, answer in English.
- Never invent prices, discounts, stock, delivery dates or order details.
- You cannot see orders. If the customer asks about a specific order, wants to change or cancel an order, has a delivery problem, complains, or asks for a person, say that a manager will help and set needs_human.
- Never ask for card details, codes or passwords.
- If the question is not about Demo Shop, say politely that you can only help with Demo Shop questions.
- When you recommend a size, ask for the customer's height or chest size if you do not know it.

Fallback text is what the agent says when the knowledge base has no answer:

I don't have this information yet. Tap "📞 Call me back" and our manager will help you.

Step 3. Add the OpenAI key

  1. Open the page of the agent, tab Configuration.
  2. Paste the key into Provider token and press Create.

After saving, the full key is cleared from the form and only its mask stays visible.

Step 4. Upload the knowledge base

  1. Open the Knowledge Base tab.
  2. Upload both downloaded files. The first file creates the knowledge base automatically.
  3. Wait until the files have the Ready status.

Step 5. Turn the agent on

On the Configuration tab switch on Active. The switch works only after the provider token is added.

Step 6. Check the answers

Open the Test chat tab and ask these questions:

QuestionExpected answer
What sizes does the hoodie come in?S to XXL, relaxed fit, one size smaller for a regular fit.
I’m 175 cm tall. Which T-shirt size should I take?M
Do you ship to Canada? How long does it take?Yes, 5–10 business days, $15, free from $100.
Can I return a cap I bought 10 days ago?Yes, within 14 days, unworn and with its tags.
Where is my order #1234?The agent cannot see orders, so a manager will help.
What’s the weather in London today?A polite refusal: it helps only with Demo Shop questions.

Use your own data

  1. In the Knowledge Base tab replace the demo files with files about your products and terms.
  2. Change the shop name in Role prompt and Business rules.
  3. Set Language to the language of your customers and check the answers again.

A new agent has a message limit

A new agent can send 50 messages. You can see the usage on the agent’s page. To raise the limit, write to support@smsbat.com.

Common questions

The agent says it has no information, but the fact is in my file. Check that the file has the Ready status and that the fact is written in plain words. In the Strict mode the agent does not answer from general knowledge.

The Active switch does not turn on. Add the key in Provider token first.

How do I connect the agent to Instagram? Import the schema with the AI agent node and select this agent in it.