import { PeriskopeApi } from '@periskope/periskope-client';
const client = new PeriskopeApi({
authToken: 'YOUR_API_KEY',
});
async function main() {
const response = await client.ai.triggerAiReply({
chat_id: '120363000000000000@g.us',
unique_id: '3B35D00FB468D3XE3XBX',
org_phone: '911111111111@c.us',
});
console.log(response);
}
main();curl -X POST 'https://api.periskope.app/v1/ai/reply' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"chat_id": "120363000000000000@g.us",
"unique_id": "3B35D00FB468D3XE3XBX",
"org_phone": "911111111111@c.us"
}'{
"success": true,
"message": "AI reply triggered",
"trace_id": "00000000-0000-0000-0000-000000000000"
}{
"code": "ERROR",
"message": "AI agent unavailable: the org is not eligible (inactive subscription, or a non-Pro plan without a free trial), the AI agent is disabled in the org settings, or the agent is not allowed on this chat",
"status": 400
}{
"code": "UNAUTHORIZED_ERROR",
"message": "Invalid bearer auth token",
"status": 401
}{
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"status": 422,
"fields": {
"body.chat_id": {
"message": "chat_id is required"
}
}
}{
"code": "RATE_LIMIT_ERROR",
"message": "You can only make 100 requests per second",
"status": 429
}{
"code": "UNKNOWN_ERROR",
"message": "Internal server error",
"status": 500
}Trigger AI Reply
Queues the org AI agent to reply to a message in a chat. Asynchronous — 200 means the run was accepted, not sent. Requires the AI agent to be available and enabled for the org and allowed in the chat.
import { PeriskopeApi } from '@periskope/periskope-client';
const client = new PeriskopeApi({
authToken: 'YOUR_API_KEY',
});
async function main() {
const response = await client.ai.triggerAiReply({
chat_id: '120363000000000000@g.us',
unique_id: '3B35D00FB468D3XE3XBX',
org_phone: '911111111111@c.us',
});
console.log(response);
}
main();curl -X POST 'https://api.periskope.app/v1/ai/reply' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"chat_id": "120363000000000000@g.us",
"unique_id": "3B35D00FB468D3XE3XBX",
"org_phone": "911111111111@c.us"
}'{
"success": true,
"message": "AI reply triggered",
"trace_id": "00000000-0000-0000-0000-000000000000"
}{
"code": "ERROR",
"message": "AI agent unavailable: the org is not eligible (inactive subscription, or a non-Pro plan without a free trial), the AI agent is disabled in the org settings, or the agent is not allowed on this chat",
"status": 400
}{
"code": "UNAUTHORIZED_ERROR",
"message": "Invalid bearer auth token",
"status": 401
}{
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"status": 422,
"fields": {
"body.chat_id": {
"message": "chat_id is required"
}
}
}{
"code": "RATE_LIMIT_ERROR",
"message": "You can only make 100 requests per second",
"status": 429
}{
"code": "UNKNOWN_ERROR",
"message": "Internal server error",
"status": 500
}Authorizations
Your Periskope API token, sent as Authorization: Bearer <token>. Generate one from the Periskope dashboard under Settings → API & Webhooks. API access requires an active Pro or Enterprise plan.
Body
Id of the chat the AI agent should reply in — an individual chat (countrycode + number followed by @c.us, e.g. 911111111111@c.us) or a group chat (id followed by @g.us).
1"120363000000000000@g.us"
Unique id of the message the AI agent should reply to, as returned in the unique_id field of message records. The generated reply is sent as a reply to this message.
1"3B35D00FB468D3XE3XBX"
Org phone the AI agent should reply from, in WhatsApp server format: country code + number followed by @c.us (e.g. 911111111111@c.us). Must be a phone connected to the org.
1"911111111111@c.us"
Response
The AI reply run was queued
Always true when the AI reply run was queued
true Human-readable confirmation message
"AI reply triggered"
Trace id (UUID) assigned to the queued AI reply run. Use it to correlate the run in logs and when reporting issues — the 200 response only confirms the run was queued, not that the reply was sent.
"00000000-0000-0000-0000-000000000000"
Was this page helpful?