AgencyMod API
Use your AgencyMod with AgencyAI in your own ticket system, website or helpdesk. It answers with everything you set up in the dashboard: name, tone, level, instructions, knowledge, documentation and what it has learned from your team.
Get started
- 01Open the dashboard, tab AI, and create a key under AgencyMod API. Copy it right away, it is shown only once.
- 02Store the key on your server. Never put it into a website, an app or anything other people can open.
- 03Send the conversation of a ticket to the API with the header Authorization: Bearer and your key.
- 04Show the answer in your ticket. If needs_team is true, notify your team.
Example
cURL
curl https://bot.agencyscripts.dev/api/v1/chat \
-H "Authorization: Bearer amk_..." \
-H "Content-Type: application/json" \
-d '{"customer":"Alex","messages":[{"role":"user","content":"How do I join the server?"}]}'JavaScript (Node.js)
const antwort = await fetch("https://bot.agencyscripts.dev/api/v1/chat", {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.AGENCYMOD_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
customer: "Alex",
messages: [
{ role: "user", content: "How do I join the server?" },
],
}),
});
const { answer, needs_team } = await antwort.json();PHP
$ch = curl_init("https://bot.agencyscripts.dev/api/v1/chat");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("AGENCYMOD_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"customer" => "Alex",
"messages" => [["role" => "user", "content" => "How do I join the server?"]],
]),
]);
$antwort = json_decode(curl_exec($ch), true);Request
POST with a JSON body. These fields are read: POST https://bot.agencyscripts.dev/api/v1/chat
messages- The conversation, oldest first, up to 20 messages. role is user for the customer and assistant for earlier bot answers, content is the text. The last message must come from the user. Required.
customer- The customer's name, so the bot can address them. Optional.
messages[].name- Inside a message: the name of the person who wrote it, useful when several people write in one ticket. Optional.
Response
JSON
{
"answer": "...",
"needs_team": false,
"bot": { "name": "AgencyMod", "avatar": "https://cdn.discordapp.com/..." },
"level": "V1",
"usage": {
"available_percent": 92.5,
"credit_percent": 0,
"requests_today": 14,
"requests_per_day": 1000,
"requests_per_minute": 20,
"premium": true
},
"ai_notice": "This answer was generated automatically by an AI (AgencyAI)."
}answer- The reply as plain text with simple markdown.
needs_team- true if a human should take over, for example for payments, bans or problems the bot can't solve.
bot- Name and avatar from your branding, to show the answer just like in Discord.
level- The AgencyAI level that answered: V1, V1.5 or V2.
usage- The remaining quota in percent, your top-up credit and your request limits.
ai_notice- A short note that the answer was written by an AI. Show it to your customers, so they always know an AI answered.
Check your quota
A GET request to /api/v1/status with the same header returns the bot's name and avatar and your remaining quota, without using any of it.
cURL
curl https://bot.agencyscripts.dev/api/v1/status \
-H "Authorization: Bearer amk_..."Limits and quota
- 01With Premium the API can use up to half of your weekly AI quota, so there is always quota left for Discord. The quota resets every Monday.
- 02When the API quota is empty, it continues with your top-up credit. Top-ups are in the dashboard, tab AI, and never expire.
- 03Without Premium you get a small trial quota on level V1. It needs at least 20 members and AgencyMod on your server for 7 days.
- 0420 requests per minute per key, 1,000 requests per day with Premium and 150 without. Up to 5 keys per server.
Errors
400- messages is missing, or the last message is not from the user.
401- The key is missing, wrong or revoked.
402- The quota is used up. Top up or get Premium.
403- The server doesn't meet the requirements for the API without Premium yet.
429- Too many requests. Wait a moment and try again.
503- AgencyAI didn't answer. Try again.
SecurityAnyone with your key uses your AI quota. If a key leaks, revoke it in the dashboard and create a new one. The API is made for calls from your server, browsers can't call it directly.
Better answersThe API uses the same knowledge as your bot in Discord. Fill in the knowledge and the documentation links in the AI tab, and approve the training suggestions from solved tickets. Every approved entry improves Discord and the API at once.
Something unclear? Open a ticket at help.agencyg.de in the AgencyMod category or ask in our Discord. Privacy policy and terms