Dragon Library
The Dragon Library is the collection of scripts that turn a prim into an in-world AI agent. dragon_api.lsl on its own is already a chatbot: say its name and it answers. Each Library part adds one kind of ability, and each is a small script with its own 64 KB of memory, so you add only the parts you want. All the thinking runs on our server (who to greet, what to say, what's allowed); the parts only notice things and carry out actions. Developers can replace any part with their own (Custom Library).
The parts
| Script | What it adds | Plan |
|---|---|---|
dragon_api.lsl | Required. The connection, plus local chat (hears its name, answers) and simple speech: say, whisper, shout, say_to, notify_owner, link_message, and the owner menu. | All |
dragon_presence.lsl | Notices people: arrivals (for the greeter) and tips (the tip jar). | All |
dragon_dialog.lsl | Asks and shows: menus, text boxes, IMs, a floating sign, web links. | All |
dragon_give.lsl | Hands things out: items, folders, rezzing. Tells the AI what's in the object, and uploads the FAQ and Knowledge notecards. | All |
dragon_effects.lsl | Puts on a show: particles, sounds, music loops, animations, colour and glow, spin. | All |
dragon_sense.lsl | Looks at the region: who's here, the parcel, performance, environment (queries). | Mind+ |
dragon_watch.lsl | Keeps watch: someone near, someone arriving, a crowd (watches). | Mind+ |
dragon_motion.lsl | Moves: follow, orbit, go to, wander (movement). | Mind+ |
dragon_shape.lsl | Changes how it looks: prim type, hollow, phantom, size, colour, glow, light (shape). | Mind+ |
dragon_land.lsl | Land security, like a security orb: eject, teleport home, ban, the access list, push, return objects; security watches that warn first (land). | Mind+ |
Common setups:
- Chatbot: just
dragon_api.lsl. - Greeter or host: API + Presence + Dialog + Give + Effects (the old all-in-one Library).
- Tip jar: API + Presence.
- Security orb: API + Watch + Land (+ Dialog for warnings).
- Everything: all ten. A Dragon Installer that drops them in for you is coming.
The AI is only offered what the object can really do: if a part is missing, it says which script to add instead of pretending.
1. Set it up
- Put
dragon_api.lslin the prim. It sends you a link: open it and sign in. - Add the parts you want to the same prim.
- Give it a name (on its dashboard page, or tell it), then talk to it: “Hey Sarah, what's new?”
Don't also use the chat example script, or the prim will answer twice. /88 settings → Status lists the parts and each script's free memory.
Setting it up
A new agent asks you to set it up the first time you talk to it. You get a window with your profiles, plus:
- Set Me Up: it asks one question at a time (its name, title and role, tasks, personality), saves each answer, and offers to save it all as a profile for other agents.
- Build a Team: it becomes the manager. Describe the team in one go if you like (“This is a bar. 5 bartenders serve drinks and answer questions; 10 servers walk the floor”). It makes a profile per role, then assigns the roles itself: your agents that aren't set up yet get one now, and every new agent you add takes the next open role automatically (Bartender 2, Server 7…).
- Later: say “set yourself up” whenever you're ready.
You can talk to any agent and change anything; you can overrule the manager. The manager can reassign its own staff, but never what you set yourself.
2. Talking to it
Local chat is handled by dragon_api.lsl itself.
- By name (default): it answers when someone says its name anywhere in a line. Follow-ups within 90 seconds don't need the name.
- Open chat: it hears everything within 20 m and joins in when it's useful (uses more AI calls in busy places).
- Off: it doesn't listen to local chat at all, for objects driven only by your own scripts.
- Who it talks to: everyone, only people wearing its group tag, or only you. Set on the Behavior tab.
As the owner, you can change it by just asking:
| You say | What happens |
|---|---|
| “Sarah, your name is now Willow.” | Renames it. |
| “Sarah, from now on you're a grumpy pirate.” | Replaces its personality. |
| “Sarah, go into open chat mode.” | Switches chat mode. |
| “Sarah, your job is to welcome shoppers and point them to the sale.” | Sets its job (what it's for). |
| “Sarah, greet people who arrive, and you can give landmarks now.” | Changes its behavior and abilities: greeter, who it talks to, moderator rules and banned words, tip jar, any tool on or off. |
| “Sarah, you're one of my Greeters.” / “Save yourself as Shopkeeper.” | Joins an agent type, or saves its setup as a new type to reuse. |
| “Sarah, what are your settings?” | Lists its current setup. |
| “Sarah, your title is Host. You're on the Moonfall Bar team.” / “Make Max the manager there.” / “Who's on my teams?” | Teams for venues and shops: each agent has a title, belongs to a named team, and one can be the team lead (manager). Agents see their team's roster, so they know who to ask. With a lead, staff pass problems up to the lead, and only the lead (or you) tells staff what to do. |
| “Sarah, tell the Shopkeeper when a VIP arrives.” | Works with your other agents: it can ask a teammate something or tell one to act where it is. Teammates never get more permissions than the person who asked. |
| “Sarah, remember the sale ends Sunday.” | Adds a fact to what it knows. |
| “Sarah, add rugs to my shopping list.” | Keeps named lists for you, shared by all your agents. “What's on my shopping list?” |
| “Sarah, Hannah Moon is my sister.” | Saves a contact. It also knows everyone your agents have met, and asks when a name is unclear. |
| “Sarah, every day at 9 AM set your sign to OPEN.” | Schedules it (Mind plan). “IM Hannah at 10 AM on Friday.” |
| “Sarah, ask your agent to research...” | Hands the task to your Agent (Agent plan). |
Sarah settings or /88 settings | Opens the owner menu: Status, Re-link, New device. |
3. Tools
The AI uses a tool when it decides to; you choose which tools each agent has on its Abilities tab. Each tool reaches the prim as an action: a JSON object with do plus the parameters below. A custom library receives exactly these on DRAGON_ACTIONS (9110), and your own scripts can send them too (hooks).
The server checks every action before it reaches the prim: only tools you've switched on, only items the prim really has, and only the owner can make it message someone else.
say( string text );dragon_apiSays an extra line in local chat (20 m). Its normal reply is already spoken, so this is for a second line. Example: "Announce the raffle!"
{"do":"say","text":"..."}
whisper( string text );dragon_apiWhispers a line (10 m). Example: "Psst, what's the secret?"
{"do":"whisper","text":"..."}
shout( string text );dragon_apiShouts a line to everyone within 100 m. Example: "Tell everyone the show starts!"
{"do":"shout","text":"..."}
- Used rarely, by instruction.
im( key to, string text );dragon_dialogSends a private instant message. Example: "IM me the shop hours."
{"do":"im","to":"<key>","to_name":"","text":"..."}
- Anyone can ask for an IM to themselves; only the owner can have it message someone else (by name, if they're nearby).
give_item( key to, string item );dragon_giveGives the person talking an item from the prim's inventory. Example: "Can I have a landmark?"
{"do":"give_item","to":"<key>","item":"..."}
- Only items really in the prim.
- Not the same item to the same person within 10 minutes.
give_folder( key to, string folder, list items );dragon_giveGives several items at once, as one folder. Example: "Starter pack please!"
{"do":"give_folder","to":"<key>","folder":"Gift","items":["...","..."]}
- Up to 10 items, all in the prim's inventory.
set_text( string text );dragon_dialogSets the floating text above the prim, like a sign. Empty text clears it. Example: "Put up a sign: back in 5."
{"do":"set_text","text":"..."}
- Up to 250 characters.
open_url( key to, string url, string text );dragon_dialogOffers to open a web page; they get a pop-up asking first. Example: "Where's your website?"
{"do":"open_url","to":"<key>","url":"https://...","text":"..."}
play_sound( string sound );dragon_effectsPlays a sound from the prim's inventory. Example: "Ring the bell!"
{"do":"play_sound","sound":"..."}
- Only sounds in the prim.
play_animation( string anim );dragon_effectsPlays one of its animations (animesh). Example: "Do a little dance."
{"do":"play_animation","anim":"..."}
- Only animations in the prim.
particles( string effect, integer seconds );dragon_effectsA particle effect: sparkles, bubbles, confetti, smoke, hearts, fire, embers, snow, rain, fireflies, fountain, vortex, stars, rainbow, mist, fireworks, halo, petals, or stop. Optional colour, fade colour, size, amount, and someone to fly to. Example: "Celebrate!" / "Snow until I say stop."
{"do":"particles","effect":"confetti","seconds":8,"rules":[...]}
- 1 to 600 seconds, or 0 = until stopped.
- The server sends the full recipe in rules, so new effects need no script update.
set_look( list color, float glow );dragon_effectsChanges its colour and glow. The AI picks a named colour (red, gold, teal...) or normal; it arrives as an RGB list. Example: "Turn red."
{"do":"set_look","color":[1,0.25,0.25],"glow":0.2}
- Off by default.
- "normal" restores the original look.
notify_owner( string text );dragon_apiPrivately tells the owner something. Example: "Tell the owner I stopped by."
{"do":"notify_owner","text":"..."}
- Also used for Agent progress and results.
say_to( key to, string text );dragon_apiSays something privately to the person talking: only they see it, in local chat. Example: "Tell me quietly."
{"do":"say_to","to":"<key>","text":"..."}
point_at( key target, integer seconds );dragon_A particle pointer: a beam to a person or object that follows it, and a private note of where it is (distance, direction, height). Example: "Where is Blake?" / "Point to the nearest prim."
{"do":"point","t":"<key>","who":"<key>","seconds":30,"rules":[...]}
- 0 seconds = until stopped (particles stop).
- Objects within 96 m are found with sense; anywhere in the region with search (owner only).
text_box( key to, string prompt );dragon_dialogAsks the person to type an answer in a box; it comes back as their next message. Example: "Can I order a custom size?"
{"do":"text_box","to":"<key>","prompt":"..."}
rez( string item );dragon_giveRezzes an object from its inventory just above itself. Example: "Can I get a gift box?"
{"do":"rez","item":"..."}
- Off by default.
- Only objects in the prim.
spin( integer on );dragon_effectsStarts or stops spinning slowly. Example: "Show me the product!"
{"do":"spin","on":true}
- Off by default.
loop_sound( string sound );dragon_effectsPlays a sound on a loop, or stops it (empty sound). Example: "Play some music."
{"do":"loop_sound","sound":"..."}
- Off by default.
- Only sounds in the prim.
link_message( integer num, string text, key to );dragon_apiTriggers your own scripts in the object. Example: "Open the door."
{"do":"link_message","num":9200,"text":"open_door","to":"<key>"}
- Arrives in your scripts as link message 9200 (see hooks).
Handled on the server
These are tools too, but they run on the server, so the prim never receives them as actions:
web_search( string query ): looks things up on the web, with clickable sources. Every plan, on by default.set_mood( string mood ): changes its mood (happy, excited, calm, sad, grumpy, sleepy, curious, neutral), which colours its tone, and its look ifset_lookis on.
4. Senses
With each request the AI is told (at no extra cost):
- where and when: region, parcel, and the time in SLT;
- what it has (from
dragon_give): names of its landmarks, notecards, objects, clothing, sounds and animations, so it knows what it can give or play; - who's nearby (from
dragon_api): avatars within 20 m, with distance, so it can greet or refer to them.
Memory and privacy
- The last hour of each conversation is kept word for word, so it can hold the conversation. Older parts are summarized, and everything can be searched by topic or date (“what did we agree about a month ago?”), with a short summary of each past day to skim first.
- Consent: you (the owner), and anyone who agrees, are remembered by name and word for word. At an important moment the agent sends the person an IM and a window, once: “May I fully record your identity and our conversations, so I remember you next time?” with an I Consent button. Otherwise, after an hour their lines are reworded, names and identifying details are removed, and they're filed under a random visitor ID that changes every hour. You can still see what visitors asked about.
- “Am I being recorded?”: the agent sends an IM explaining exactly that, and a window asking whether it may keep the record with their identity hidden: Keep It Hidden or Forget Me Entirely. Buttons take effect instantly. (Needs
dragon_dialog.lsl; without it the agent asks in words.) - “Forget me” (or Forget Me Entirely): everything linked to them is erased, and from then on nothing is kept after the conversation, not even the reworded version.
- Your consented list: staff, partners or friends who told you they agree. “Add Hannah to my consented list.”
- Chat overheard in open mode or for moderation is never stored. The AI providers we use don't keep or train on what's said.
5. Behaviors
| Behavior | What it does | Where to set it |
|---|---|---|
| Greeter | Greets people who arrive within 20 m, by name, personally if it remembers them. Not the same person twice within 12 hours. Needs dragon_presence. | Behavior tab |
| Moderator | Checks local chat against your banned words and plain-English rules; warns politely and/or tells you. | Behavior tab |
| Tip jar | Shows a pay button and thanks tippers by name. The L$ go straight to you. Needs dragon_presence. | Behavior tab |
| FAQ | Answers your listed questions instantly and for free, without calling the AI. | Identity tab or a notecard |
| Moods | Its mood shifts with the conversation and colours its tone. | Abilities tab (set_mood) |
Notecards: drop a notecard named FAQ or Knowledge into the prim and dragon_give uploads it automatically whenever you change it. FAQ format:
Q: What are your hours? A: Every day, 9 AM to 11 PM SLT. Q: Do you ship? A: Everything is delivered instantly to your inventory.
6. Hooks for your scripts
How your own scripts in the same object work with the agent.
integer DRAGON_REQUEST = 9100; // ask the AI yourself (see the API guide) integer DRAGON_REPLY = 9101; // hear every reply integer DRAGON_ACTIONS = 9110; // make the agent act integer DRAGON_COMMAND = 9200; // the AI triggers your script
link_message( integer sender, integer DRAGON_COMMAND, string command, key who ){ ; }9200The AI decided to trigger your script, using the link_message tool.
- string command – the command the AI chose, as plain text: whatever you described in the agent's knowledge, e.g.
open_door. - key who – the avatar who asked, or
NULL_KEY.
Caveats
- Switch on
link_messageon the agent's Abilities tab, and tell it your commands in its knowledge, e.g. “To open the door, send the command open_door.” - Sent to every prim in the object (
LINK_SET), so your script can be in any prim. - The AI chooses the text, so check for exact commands and ignore anything else. Use who if only some people may trigger it.
Example
// door.lsl: anywhere in the same object
default
{
link_message(integer sender, integer num, string command, key who)
{
if (num != 9200) return;
if (command == "open_door") llSetPrimitiveParams([PRIM_PHANTOM, TRUE]);
else if (command == "close_door") llSetPrimitiveParams([PRIM_PHANTOM, FALSE]);
}
}
llMessageLinked( LINK_THIS, DRAGON_ACTIONS, string actions, NULL_KEY );9110Makes the agent act right now, without asking the AI. For example, when your vendor makes a sale.
- string actions – required: a JSON list of actions, e.g.
[{"do":"say","text":"Hi!"}]. - key id – ignored.
Caveats
- Up to 8 actions per message; extra ones are ignored.
- Sent from your own script, these aren't checked against the agent's abilities: your script is trusted.
- Send from a script in the same prim as
dragon_api.lsl; each part picks out its own actions (speech is done by the API itself).
Example
llMessageLinked(LINK_THIS, 9110, llList2Json(JSON_ARRAY, [
llList2Json(JSON_OBJECT, ["do", "particles", "effect", "confetti", "seconds", 6]),
llList2Json(JSON_OBJECT, ["do", "say", "text", "Thank you for your purchase!"])
]), NULL_KEY);
link_message( integer sender, integer DRAGON_REPLY, string reply, key request_id ){ ; }9101Every reply the agent gives also reaches your scripts, so they can react: log it, animate, show it on a screen. The spoken line is in text; all fields are in the API guide.
link_message(integer sender, integer num, string str, key id)
{
if (num == 9101) llSetText(llJsonGetValue(str, ["text"]), <1, 1, 1>, 1.0);
}
Ask it something from your script with DRAGON_REQUEST (9100).