AICord Applets
Welcome to the AICord Applet System! Applets are tiny JavaScript tools that let your AI characters do powerful things - like pulling live data, reacting to server events, or integrating with external services. No big setup, no bloated codebase - just one file, one idea.
Applets let your characters do real-world tasks — call APIs, fetch data, trigger webhooks — giving them agentic capabilities beyond just conversation.
✨ What’s an Applet?
An applet is a simple .js
file hosted on GitHub that contains one or more named functions. AICord runs them in a safe sandbox and invokes the appropriate one based on context (like a user message, or Discord event).
Think of applets like "mini apps" your characters can use. They're plug-and-play extensions of their minds.
📦 What Does an Applet Look Like?
Here’s the simplest applet:
export async function run(input) {
return "Hello from my applet!";
}
Or add multiple event handlers:
export async function run({ city }) {
const res = await fetch(`https://wttr.in/${city}?format=3`);
return await res.text();
}
export async function onGuildMemberAdd({ user }) {
return `Welcome ${user.username}! 🎉`;
}
Your AI character will call the right function when it needs it.
⚡ Supported Functions
Each function gets the inputs as one input
param, and you need to unbox it.
run(input)
This is the default function. AI uses the applet as a tool (for example when user asks about weather)
Anything your applet requires
onGuildMemberAdd({user})
A user joins the server
Discord user
object within user
value
🧠 Agentic AI + Applets = Magic
Applets power your AI characters to interact with the world. With applets, they can:
Fetch stock prices
Call APIs like OpenWeather or HuggingFace
Send Discord messages
React to users joining
Access user-provided secrets (API keys)
It’s like giving your AI a Swiss Army knife — and you control what tools it gets.
🔐 Using Secrets
Add placeholders like:
const API_KEY = "{{OPENWEATHER_KEY}}";
When run, AICord will inject the actual secret. You keep your code clean and safe. Secrets for applets can be defined on AICord Dashboard.
If your applet is public and someone clones it, they will need to add their own API keys so not yours is used.
Never hardcode your actual secrets & keys into the code directly!!! Especially when the GitHub repo and Applet is public.
✅ What’s Allowed in Applets
Since Applets are executed as serverless functions in a safe container, there are some limitations. AICord Team is always working on extending these to allow you to use truly anything!
✅
fetch()
— Make external API calls✅
console.log()
— Logs visible in your dashboard✅ Use
export function
style syntax✅ Use multiple named exports
✅ AICord passes some common and popular modules to your code automatically without you having to import them. You can suggest modules in Discord server.
🚫 3rd party
import
/require
— Not supported (yet!)🚫
fs
or file system access🚫 Long-running code (>60s timeout)
Note: You can still expose helper functions within your file and AICord will run it in a controlled Node.js VM with specific permissions you configure.
🌤 Sample Applet: Weather
export async function run({ city }) {
const res = await fetch(`https://wttr.in/${city}?format=3`);
return await res.text();
}

⚙️ How Applets Work Behind the Scenes
1. AICord fetches your applet file from GitHub.
2. It replaces all {{secrets}} placeholders.
3. The code is sandboxed and compiled.
4. When an event or tool call happens, the matching function is executed.
Events are dynamically routed. If your applet exports onGuildMemberAdd
, it runs only when a user joins.
🧪 How to Build Your Applet (more details soon)
Create a public GitHub repo (e.g.,
aicordapp/weather-bot
)Add your code in
applet.js
You should use themain
branch onlyUse the following config inside AICord Dashboard when creating an applet: (wrong example, will be updated!)
{
"repo": "aicordapp/weather-bot",
"codePath": "mycode.js",
}
Once saved, you can trigger tool runs or wait for event hooks (like user joins).
Last updated