Integration guide
Connect your management system to a BotBaseX Management Agent, step by step, from API connection to the first signed-in chat.
This guide takes a developer from zero to a working Management Agent inside their own application. Plan about an hour for a first set-up.
You need: a BotBaseX account on Pro (or the 14-day trial), an HTTPS API for your system that BotBaseX can reach from the internet, and the ability to add one route to your backend.
#1. Create the Management Agent
Start a new assistant
In the dashboard choose New assistant → BotBaseX Management Agent. Give it a name (for example Msaidizi wa Shule) and your organisation's name.
Open the Management system tab
After creation you land on the agent's Management system tab. It shows a set-up checklist that turns green as you go, and the Go live button unlocks when every item is done.
#2. Connect your system's API
Click Open connection setup. This is the same connection screen used for business-platform integrations.
- Base URL, for example
https://api.myschool.ac.tz. - Authentication: none, API key (header name + key), bearer token, basic auth or OAuth2 client credentials. Credentials are encrypted and never shown again.
- Operations: one per task the agent may perform. For each operation you set:
- a key (
get_attendance), a label and a description the AI reads; - method and path, with variables in double braces:
/v1/classes/{{class_id}}/attendance; - the inputs (text, number, true/false or date) and which are required;
- the response mapping: which fields of the JSON reply the agent may read. Unmapped fields never reach the AI, so you can hide columns such as national ID numbers.
- a key (
- You can also import operations from an OpenAPI file and edit them.
- Test the connection and test each operation. An operation can only be used after it passes a test with the current settings; changing it requires a new test.
- Allow each operation, then make the connection live.
GET operations are lookups. POST, PUT and PATCH change data and always require the user's confirmation before they run.
#3. Define roles and permissions
In Roles and permissions, add the roles your system uses and tick what each may do. Role keys are generated from the name (Head teacher becomes head_teacher). Your backend sends these same keys when it starts a session. See Roles and permissions.
#4. Lock inputs to the signed-in user (optional)
In Limit lookups to the signed-in user, bind an input to the session so the AI cannot choose it:
| Binding | Value used |
|---|---|
user.id | the user id your server sent |
user.name | the display name your server sent |
attr.school_id (any attr.<name>) | an attribute your server sent |
Example: bind my_classes.teacher_id to user.id. A teacher can then only ever list their own classes, even if they ask for someone else's.
#5. Create the server key
Under Connect your application, click Create server key and store it in your backend's environment, for example BOTBASEX_SERVER_KEY. It starts with bbx_mgmt_, is shown once, and only its hash is stored by BotBaseX. Rotating it disables the old key immediately.
Optionally set:
- Allowed websites: the origins of your management system, for example
https://sms.myschool.ac.tz. Browser calls from other sites are refused. - Session length: 5–60 minutes (default 15). The widget renews sessions automatically.
- Actor signing secret: lets your API verify who is acting. See Security model.
#6. Add a session route to your backend
Your backend already knows who is logged in. Add a route that asks BotBaseX for a session for that user and returns only the session token to the browser.
// env = your server's environment variables
// GET /botbasex/session — behind your normal login middleware
app.get("/botbasex/session", requireLogin, async (req, res) => {
const r = await fetch("https://api-v2.botbasex.com/management/v1/sessions", {
method: "POST",
headers: {
Authorization: `Bearer ${env.BOTBASEX_SERVER_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
user: {
id: String(req.user.id),
name: req.user.fullName,
roles: req.user.roles, // e.g. ["teacher"]
attributes: { school_id: req.user.schoolId },
},
}),
});
if (!r.ok) return res.status(502).json({ error: "assistant unavailable" });
const { session_token } = await r.json();
res.json({ session_token });
});Use the API host shown in your dashboard snippet if it differs from the examples.
#7. Add the assistant to your pages
Add one script tag to the pages of your system where staff should see the assistant (after login):
<script src="https://api-v2.botbasex.com/widget.js" data-session-url="/botbasex/session" async></script>data-session-url is the route from step 6 on your site. The widget calls it with the user's own login cookie, receives the session token, loads the assistant and renews the token when it expires. No agent token or secret appears in the page. Your Pro widget design (colours, shape, position) applies here too.
#8. Test as each role
In Test as a role, choose one or more roles (and attributes such as {"school_id": "S-1"}), then chat. Lookups use your real system; actions that change data are simulated in test mode. Check that:
- each role can do what it should;
- each role is refused what it should not (check the refusal in the audit log);
- bound inputs really limit results to the test user.
#9. Go live
When the checklist is complete, click Go live. Your server can now create sessions. You can Pause at any time; sessions stop working immediately.
#Checklist
| Item | Where |
|---|---|
| API connection created, operations tested and allowed, connection live | Open connection setup |
| At least one role with at least one operation | Roles and permissions |
| Server key created and stored on your server | Connect your application |
| Session route added to your backend | Your code |
| Script tag added to your pages | Your code |
| Tested as each role | Test as a role |