Triggers API: Create and Manage Automations
Automate Forjinn chatflow executions with cron-based schedules or incoming webhooks from Telegram, Slack, and other platforms, and retrieve execution results.
Triggers let you run chatflow executions automatically — either on a schedule (cron) or in response to an incoming HTTP request (webhook). A trigger is always associated with a specific chatflow and node within that flow. When a trigger fires, Forjinn runs the chatflow with the configured payload and records the result.
Trigger types
| Type | Description |
|---|---|
cron | Executes on a schedule defined by a cron expression |
webhook | Executes when a POST request arrives at the trigger's webhook URL |
Webhook triggers support several platform integrations (e.g., Telegram) that handle signature verification automatically when you provide a webhookSecret or webhookBotToken.
The trigger object
idstringUUID of the trigger.
namestringDisplay name.
chatflowIdstringThe chatflow this trigger executes.
nodeIdstringThe specific node within the chatflow that receives the trigger payload.
typestring"cron" or "webhook".
cronExpressionstringCron expression (e.g., "30 9 * * *" for daily at 09:30). Present on cron triggers only.
enabledbooleanWhether the trigger is active.
webhookPlatformstringFor webhook triggers, the source platform (e.g., "telegram").
webhookSecretstringSecret used to verify incoming webhook signatures.
triggerMessagestringMessage text sent to the chatflow when the trigger fires (for cron triggers).
executionCountintegerTotal number of times this trigger has fired.
maxExecutionsintegerOptional cap on total executions. Once reached, the trigger stops firing.
timeoutintegerExecution timeout in seconds (default: 300).
lastExecutedstringISO 8601 timestamp of the most recent execution.
nextExecutionstringISO 8601 timestamp of the next scheduled execution (cron triggers only).
notificationEmailstringOptional email address to notify on execution failure.
createdDatestringISO 8601 creation timestamp.
updatedDatestringISO 8601 last-updated timestamp.
Create a trigger
POST /api/v1/triggersnamestringRequiredDisplay name for the trigger.
chatflowIdstringRequiredUUID of the chatflow to execute.
nodeIdstringRequiredID of the node within the chatflow that handles trigger input.
typestringRequired"cron" or "webhook".
cronExpressionstringRequired when type is "cron". Standard 5-field cron expression (minute hour day month weekday).
triggerMessagestringMessage sent to the chatflow on each cron execution.
enabledbooleanWhether to activate the trigger immediately (default: true).
webhookPlatformstringPlatform for webhook triggers. Use "telegram" to enable Telegram-specific handling.
webhookSecretstringShared secret for verifying webhook payloads.
webhookBotTokenstringTelegram bot token. When provided alongside webhookPlatform: "telegram", Forjinn registers the webhook with Telegram automatically.
maxExecutionsintegerMaximum number of times this trigger will fire before disabling itself.
timeoutintegerExecution timeout in seconds (default: 300).
notificationEmailstringEmail address to notify on execution failure.
Example — cron trigger
curl -X POST https://your-forjinn-instance.com/api/v1/triggers \
-H "Authorization: Bearer fj-abc123def456" \
-H "Content-Type: application/json" \
-d '{
"name": "Daily Morning Briefing",
"chatflowId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"nodeId": "trigger-node-001",
"type": "cron",
"cronExpression": "0 8 * * *",
"triggerMessage": "Generate today'\''s news summary for the sales team.",
"enabled": true,
"notificationEmail": "ops@example.com"
}'const response = await fetch('https://your-forjinn-instance.com/api/v1/triggers', {
method: 'POST',
headers: {
'Authorization': 'Bearer fj-abc123def456',
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Daily Morning Briefing',
chatflowId: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
nodeId: 'trigger-node-001',
type: 'cron',
cronExpression: '0 8 * * *',
triggerMessage: "Generate today's news summary for the sales team.",
enabled: true,
notificationEmail: 'ops@example.com',
}),
});
const trigger = await response.json();Response — 201 Created
{
"id": "d4e5f6a7-b8c9-0123-def0-123456789012",
"name": "Daily Morning Briefing",
"chatflowId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"nodeId": "trigger-node-001",
"type": "cron",
"cronExpression": "0 8 * * *",
"triggerMessage": "Generate today's news summary for the sales team.",
"enabled": true,
"executionCount": 0,
"timeout": 300,
"notificationEmail": "ops@example.com",
"nextExecution": "2024-05-02T08:00:00.000Z",
"createdDate": "2024-05-01T10:00:00.000Z",
"updatedDate": "2024-05-01T10:00:00.000Z"
}Example — webhook trigger
curl -X POST https://your-forjinn-instance.com/api/v1/triggers \
-H "Authorization: Bearer fj-abc123def456" \
-H "Content-Type: application/json" \
-d '{
"name": "GitHub PR Webhook",
"chatflowId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"nodeId": "webhook-node-002",
"type": "webhook",
"webhookSecret": "my-github-secret",
"enabled": true
}'const response = await fetch('https://your-forjinn-instance.com/api/v1/triggers', {
method: 'POST',
headers: {
'Authorization': 'Bearer fj-abc123def456',
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'GitHub PR Webhook',
chatflowId: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
nodeId: 'webhook-node-002',
type: 'webhook',
webhookSecret: 'my-github-secret',
enabled: true,
}),
});Once created, the webhook URL for this trigger is:
POST /api/v1/triggers/webhook/<nodeId>List triggers
GET /api/v1/triggersReturns all triggers in your active workspace.
includeResultsbooleanIf true, each trigger in the response includes a recentResults array with its last few execution outputs.
curl "https://your-forjinn-instance.com/api/v1/triggers?includeResults=true" \
-H "Authorization: Bearer fj-abc123def456"const response = await fetch('https://your-forjinn-instance.com/api/v1/triggers?includeResults=true', {
headers: { 'Authorization': 'Bearer fj-abc123def456' },
});
const triggers = await response.json();Get a trigger
GET /api/v1/triggers/:ididstringRequiredUUID of the trigger.
curl https://your-forjinn-instance.com/api/v1/triggers/d4e5f6a7-b8c9-0123-def0-123456789012 \
-H "Authorization: Bearer fj-abc123def456"const id = 'd4e5f6a7-b8c9-0123-def0-123456789012';
const response = await fetch(`https://your-forjinn-instance.com/api/v1/triggers/${id}`, {
headers: { 'Authorization': 'Bearer fj-abc123def456' },
});
const trigger = await response.json();Get trigger execution results
GET /api/v1/triggers/:id/resultsReturns the most recent execution records for a trigger — what message was sent and what the chatflow responded.
idstringRequiredUUID of the trigger.
limitintegerMaximum number of results to return (default: 10).
curl "https://your-forjinn-instance.com/api/v1/triggers/d4e5f6a7-b8c9-0123-def0-123456789012/results?limit=5" \
-H "Authorization: Bearer fj-abc123def456"const id = 'd4e5f6a7-b8c9-0123-def0-123456789012';
const response = await fetch(`https://your-forjinn-instance.com/api/v1/triggers/${id}/results?limit=5`, {
headers: { 'Authorization': 'Bearer fj-abc123def456' },
});
const results = await response.json();Response — 200 OK
[
{
"executedAt": "2024-05-02T08:00:03.000Z",
"input": "Generate today's news summary for the sales team.",
"output": "Here is today's briefing: Markets opened higher following...",
"sourceDocuments": null,
"usedTools": null,
"chatId": "trigger-d4e5f6a7-1714636800000"
}
]Update a trigger
PUT /api/v1/triggers/:ididstringRequiredUUID of the trigger to update.
Send only the fields you want to change. Updating a trigger briefly deactivates it, applies the changes, and reactivates it if enabled is true.
namestringUpdated display name.
cronExpressionstringUpdated cron expression.
triggerMessagestringUpdated message sent on each execution.
enabledbooleanEnable or disable the trigger.
maxExecutionsintegerUpdated execution cap.
curl -X PUT https://your-forjinn-instance.com/api/v1/triggers/d4e5f6a7-b8c9-0123-def0-123456789012 \
-H "Authorization: Bearer fj-abc123def456" \
-H "Content-Type: application/json" \
-d '{
"cronExpression": "0 9 * * 1-5",
"triggerMessage": "Generate today'\''s briefing (weekdays only)."
}'const id = 'd4e5f6a7-b8c9-0123-def0-123456789012';
const response = await fetch(`https://your-forjinn-instance.com/api/v1/triggers/${id}`, {
method: 'PUT',
headers: {
'Authorization': 'Bearer fj-abc123def456',
'Content-Type': 'application/json',
},
body: JSON.stringify({
cronExpression: '0 9 * * 1-5',
triggerMessage: "Generate today's briefing (weekdays only).",
}),
});
const updated = await response.json();Delete a trigger
DELETE /api/v1/triggers/:ididstringRequiredUUID of the trigger to delete.
Deletes the trigger and immediately stops any scheduled or webhook-based execution. Returns 204 No Content on success.
curl -X DELETE https://your-forjinn-instance.com/api/v1/triggers/d4e5f6a7-b8c9-0123-def0-123456789012 \
-H "Authorization: Bearer fj-abc123def456"const id = 'd4e5f6a7-b8c9-0123-def0-123456789012';
await fetch(`https://your-forjinn-instance.com/api/v1/triggers/${id}`, {
method: 'DELETE',
headers: { 'Authorization': 'Bearer fj-abc123def456' },
});
// 204 No Content on successIncoming webhook endpoint
This is the public endpoint that external services POST to in order to fire a webhook trigger. No API key is required — authentication is handled via the webhookSecret you configured on the trigger.
POST /api/v1/triggers/webhook/:nodeIdnodeIdstringRequiredThe nodeId of the trigger (matches the nodeId field on the trigger object).
Send any JSON payload. Forjinn passes the raw body and headers to the chatflow for processing.
# Example: simulating a GitHub push event
curl -X POST https://your-forjinn-instance.com/api/v1/triggers/webhook/webhook-node-002 \
-H "Content-Type: application/json" \
-H "X-Hub-Signature-256: sha256=abc123..." \
-d '{
"action": "opened",
"pull_request": {
"title": "Add new feature",
"body": "This PR adds X and Y.",
"user": { "login": "dev-user" }
}
}'const response = await fetch('https://your-forjinn-instance.com/api/v1/triggers/webhook/webhook-node-002', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
action: 'opened',
pull_request: {
title: 'Add new feature',
body: 'This PR adds X and Y.',
user: { login: 'dev-user' },
},
}),
});
const result = await response.json();The response is the chatflow's output for this execution, returned synchronously.
Document Store — Manage Vector Knowledge Bases
Create and manage Forjinn document stores: upload and chunk documents, configure vector store and embeddings, run semantic search, and track ingestion jobs.
Forjinn Deployment Guide | Docker, Kubernetes & Cloud Setup
Complete deployment guide for Forjinn AI Agent Builder. Deploy on Docker, Kubernetes, AWS, Azure, GCP with enterprise-grade scalability and security.