Guide › Setting up › Install in your app
Give the assistant tools
A tool is one thing the assistant may do in your app. It starts with none; you add the ones each person may use.
- What it’s for
- Tools are the actions the assistant can take in your app, such as “look up a booking” or “extend a booking”. Out of the box it has none, so it can only chat. Each tool is a small piece of code that uses something your app can already do.
- Who does it
- Your developer. You decide which actions you want; they write them.
- You’ll know it worked when
- Ask the assistant to do one of them, such as “find tomorrow’s bookings”, and it does it (or, for a change, shows you a card to approve first).
Deciding which tools you want
- Start with looking things up. Tools that only read, like finding a booking, are safe to start with: they change nothing.
- Then add changes people make often, like extending a booking. The assistant always shows these on a card for a person to approve first, until you decide otherwise on the Skills page.
- Only what that person could already do. A staff member’s assistant should only have the tools that staff member could use in your app.
Asking someone else to do it
Copy this and send it to your developer, or paste it into an AI coding assistant working in your app:
Please give our Cognolo assistant these tools: [list the actions, e.g. find bookings, extend a booking]. Each is a `defineTool` in our code that calls our existing functions, with our own permission checks, and is added to `toolsFor` only for people allowed to use it. Details are in Cognolo’s guide, “Give the assistant tools”.
For your developer
A tool is one thing the assistant may do in your app, such as finding a booking or extending one. The assistant can call nothing else. It starts with none, so until you add some it can only talk. Tools are grouped into skills, and trust is set per skill on the Skills page.
How risky a tool is
Every tool says how risky it is. That decides what happens before it runs:
read- Only looks. Runs at once.
write- Changes something that can be put back. A person approves it first, until the skill has earned more trust.
irreversible- Sends, charges or deletes. A person always approves it; it never goes above Suggest.
draft- Saves something only the person can see, and nothing else. It is treated exactly like a write until you confirm it on the Skills page.
Writing one
import { defineTool } from "@cognolo/runtime";
import { z } from "zod";
const input = z.object({ bookingId: z.string(), days: z.number().int().min(1).max(14) });
export const extendBooking = defineTool<Ctx, typeof input>({
name: "extend_booking",
title: "Extend a booking",
description: "Moves a booking's end date later. Use it when someone asks for more days.",
risk: "write",
input,
preview: (ctx, i) => `Extend booking ${i.bookingId} by ${i.days} days.`,
run: async (ctx, i) => {
await extendBookingAsUser(ctx.userId, i.bookingId, i.days); // your app's own code and checks
return { ok: true, data: { bookingId: i.bookingId } };
},
});name- Lower case with underscores, such as
extend_booking. title- A short label people see, such as “Extend a booking”.
description- What it does and when to use it, written for the model.
input- What it takes, as a zod schema. Every call is checked against it before it runs, so made-up or malformed values never reach your code.
preview- One plain sentence saying exactly what will happen, shown on the card before a person approves.
run- Does the work, as the signed-in person, through your app’s own code. Return
{ ok: true, data }, or{ ok: false, error }when it can’t.
Only the tools this person may use
toolsFor in lib/cognolo/assistant.ts returns the tools for one person. Give each person only the tools they could use in your app anyway: a tool someone may not use shouldn’t be in their list at all.
function toolsFor(userId: string): ToolDef<Ctx>[] {
return [findBookings, extendBooking];
}Keep your app’s own permission checks inside run. Cognolo’s rules and trust settings are added on top of them, never instead.