Slack & Discord Webhooks
Get real-time notifications for policy violations, PII detection, HITL approval requests, and other governance events directly in your team's Slack or Discord channels.
Overview
Tork's webhook integration allows you to receive instant notifications when important governance events occur. Connect your Slack or Discord workspace to stay informed about your AI agents' activities in real-time.
Policy Violations
Get alerted when agents violate defined policies
PII Detection
Notifications when sensitive data is detected
HITL Requests
Approval requests sent directly to your channel
Budget Alerts
Warnings when spending approaches limits
Supported Events
Slack Setup
Follow these steps to connect Tork with your Slack workspace:
Create a Slack App
Go to api.slack.com/apps and click "Create New App". Choose "From scratch" and give it a name like "Tork Governance".
Enable Incoming Webhooks
In your app settings, navigate to "Incoming Webhooks" and toggle it on. Click "Add New Webhook to Workspace" and select the channel for notifications.
Copy Webhook URL
Copy the webhook URL that looks like:https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
Add to Tork Admin Console
Go to Admin Console → Webhooks → Add Webhook. Paste your Slack webhook URL and select the events you want to receive.
Security Note
Discord Setup
Follow these steps to connect Tork with your Discord server:
Open Server Settings
Right-click your server name and select "Server Settings", then navigate to "Integrations" in the sidebar.
Create Webhook
Click "Webhooks" then "New Webhook". Give it a name like "Tork Alerts" and select the channel where you want notifications to appear.
Copy Webhook URL
Click "Copy Webhook URL". It will look like:https://discord.com/api/webhooks/000000000000000000/XXXXXXXXXXXXXXXXXXXXXXXXXXXX
Add to Tork Admin Console
Go to Admin Console → Webhooks → Add Webhook. Paste your Discord webhook URL and select the events you want to receive.
Webhook Payload Format
Tork sends webhook payloads in the following JSON format:
{
"event": "policy.violation",
"timestamp": "2026-01-19T10:00:00Z",
"agent_id": "agent-123",
"agent_name": "Customer Support Bot",
"severity": "high",
"details": {
"policy_id": "pol-456",
"policy_name": "no-pii-in-responses",
"action": "blocked",
"message": "PII detected in agent response",
"matched_rules": ["email_pattern", "phone_pattern"],
"context": {
"user_id": "user-789",
"session_id": "sess-abc"
}
},
"meta": {
"request_id": "req-xyz",
"organization_id": "org-123"
}
}Event Types
| Event | Description | Severity |
|---|---|---|
policy.violation | Agent violated a defined policy | high |
pii.detected | PII found in agent input/output | medium-high |
hitl.requested | Human approval requested | info |
hitl.approved | Action was approved | info |
hitl.rejected | Action was rejected | warning |
budget.warning | Approaching budget limit (80%) | warning |
budget.exceeded | Budget limit exceeded | critical |
agent.blocked | Agent was blocked from action | high |
circuit_breaker.triggered | Circuit breaker activated | critical |
Code Examples
If you want to send custom notifications programmatically, here are examples for both platforms:
import requests
def send_slack_notification(webhook_url: str, event: dict):
"""Send a Tork event to Slack."""
# Map severity to colors
colors = {
"critical": "#dc2626", # red
"high": "#f97316", # orange
"warning": "#eab308", # yellow
"info": "#3b82f6", # blue
}
payload = {
"attachments": [{
"color": colors.get(event["severity"], "#6b7280"),
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": f"🚨 {event['event'].replace('.', ' ').title()}"
}
},
{
"type": "section",
"fields": [
{"type": "mrkdwn", "text": f"*Agent:*\n{event['agent_name']}"},
{"type": "mrkdwn", "text": f"*Severity:*\n{event['severity'].upper()}"},
{"type": "mrkdwn", "text": f"*Time:*\n{event['timestamp']}"},
{"type": "mrkdwn", "text": f"*Action:*\n{event['details']['action']}"},
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": f"*Message:*\n{event['details']['message']}"
}
},
{
"type": "actions",
"elements": [{
"type": "button",
"text": {"type": "plain_text", "text": "View in Console"},
"url": f"https://app.tork.network/admin/alerts/{event['meta']['request_id']}"
}]
}
]
}]
}
response = requests.post(webhook_url, json=payload)
return response.status_code == 200API Reference
Manage your Slack and Discord integrations programmatically using the REST API.
/api/v1/integrationsList all chat integrations for your organization.
curl https://api.tork.network/v1/integrations \
-H "Authorization: Bearer YOUR_API_KEY"/api/v1/integrationsCreate a new Slack or Discord integration.
curl -X POST https://api.tork.network/v1/integrations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"platform": "slack",
"name": "Engineering Alerts",
"slack_webhook_url": "https://hooks.slack.com/services/...",
"slack_channel_name": "#tork-alerts",
"events": ["policy.violation", "pii.detected", "hitl.pending"],
"notification_settings": {
"include_details": true,
"mention_on_critical": true,
"quiet_hours_start": "22:00",
"quiet_hours_end": "08:00"
}
}'/api/v1/integrations/:id/testSend a test notification to verify your integration works.
curl -X POST https://api.tork.network/v1/integrations/int_xxx/test \
-H "Authorization: Bearer YOUR_API_KEY"/api/v1/integrations/:idUpdate an existing integration.
curl -X PATCH https://api.tork.network/v1/integrations/int_xxx \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"events": ["policy.violation", "security.alert"],
"is_active": true
}'/api/v1/integrations/:idDelete an integration.
curl -X DELETE https://api.tork.network/v1/integrations/int_xxx \
-H "Authorization: Bearer YOUR_API_KEY"Notification Settings
| Setting | Type | Description |
|---|---|---|
include_details | boolean | Include event data fields in notifications |
mention_on_critical | boolean | @channel/@everyone for critical events |
quiet_hours_start | string (HH:MM) | Start of quiet hours (no notifications) |
quiet_hours_end | string (HH:MM) | End of quiet hours |
Troubleshooting
Messages not appearing in Slack/Discord
- Verify the webhook URL is correct and hasn't been regenerated
- Check that the webhook is enabled in Tork Admin Console
- Ensure the selected events match what you're testing
- Check the Tork webhook delivery logs for errors
Webhook returns 400 or 403 errors
- The webhook URL may have been revoked - create a new one
- Check if your Slack app or Discord webhook has the necessary permissions
- Verify there are no IP restrictions blocking Tork's servers
Rate limiting issues
- Slack allows ~1 message per second per webhook
- Discord allows 30 requests per minute per webhook
- Consider batching notifications for high-volume scenarios
- Use Tork's built-in rate limiting options in webhook settings
Testing your webhook
Use the Tork Admin Console to send a test notification:
# Or use the CLI
tork webhooks test --id webhook-123 --event policy.violation