Approval

Route tool approvals to Slack, Discord, Telegram, or any channel before agents execute dangerous operations

Route tool approvals to Slack, Discord, Telegram, a webhook, or a local dashboard. Agents pause before executing dangerous tools and wait for human approval via your chosen platform.

python
from praisonaiagents import Agent
from praisonai.bots import SlackApproval

agent = Agent(
    name="assistant",
    instructions="Help users with system tasks",
    tools=["execute_command"],
    approval=SlackApproval(channel="#approvals"),
)
agent.start("Delete old log files")
Diagram

Messaging Platforms

Agent calls dangerous tool

No

Yes

yes

yes

✅ Approve

approved

🔧 Tool Call

🔒 Approval
Required?

✅ Execute

📱 Backend

💬 Slack
Block Kit message

🎮 Discord
Rich embed

✈️ Telegram
Inline keyboard

🌐 Webhook / HTTP

Quick Start

  1. Pick a backend

    Choose your approval channel. Each backend reads its token from an environment variable:

    BackendCommandRequired Env Vars
    Slack--approval slackSLACK_BOT_TOKEN, SLACK_CHANNEL
    Discord--approval discordDISCORD_BOT_TOKEN, DISCORD_CHANNEL_ID
    Telegram--approval telegramTELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID
  2. Set environment variables
    bash
    # Slack
    export SLACK_BOT_TOKEN=xoxb-your-token
    export SLACK_CHANNEL=C0123456789  # or #channel-name
    
    # Discord
    export DISCORD_BOT_TOKEN=your-bot-token
    export DISCORD_CHANNEL_ID=123456789
    
    # Telegram
    export TELEGRAM_BOT_TOKEN=123456:ABC-DEF
    export TELEGRAM_CHAT_ID=your-chat-id
  3. Run with –approval
    bash
    praisonai "deploy to production" --approval slack
    
    praisonai "delete old logs" --approval discord
    
    praisonai "clean up temp files" --approval telegram

CLI Commands

The --approval flag works with all CLI commands:

bash
# Direct prompt
praisonai "task" --approval slack

praisonai "task" --approval telegram

praisonai "task" --approval discord

All CLI Approval Flags

FlagDescriptionExample
--approval <backend>Route approvals to a platform--approval slack
--trustAuto-approve all tools (skip prompts)--trust
--approve-level <level>Auto-approve up to a risk level--approve-level high
--approve-all-toolsRequire approval for all tools, not just dangerous ones--approve-all-tools
--approval-timeout <sec>Override backend timeout--approval-timeout 60

Available Backends

ValueWhat HappensEnv Vars
consoleInteractive terminal prompt (default)—
slackSlack Block Kit message → reply “yes”/”no”SLACK_BOT_TOKEN, SLACK_CHANNEL
telegramTelegram inline keyboard buttonsTELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID
discordDiscord embed → text reply “yes”/”no”DISCORD_BOT_TOKEN, DISCORD_CHANNEL_ID
webhookPOST to HTTP endpoint → poll for decisionAPPROVAL_WEBHOOK_URL
httpLocal web dashboard (browser)—
agentDelegate to an AI reviewer agent—
autoAuto-approve everything (same as --trust)—
noneDisable approval entirely—

Programmatic Usage

Slack

python
from praisonaiagents import Agent
from praisonai.bots import SlackApproval

agent = Agent(
    name="assistant",
    instructions="Help users with system tasks",
    tools=["execute_command"],
    approval=SlackApproval(channel="#approvals"),
)
agent.start("Delete old log files")

The Slack bot token needs chat:write and channels:history (or im:history for DMs) scopes.

ParameterDefaultDescription
tokenSLACK_BOT_TOKEN envSlack bot token (xoxb-...)
channelSLACK_CHANNEL env, or bot’s own DMChannel ID, #name, or user ID
timeout300 (5 min)Seconds to wait for response
poll_interval3.0Seconds between reply polls
Diagram
SlackSlackApprovalAgentSlackSlackApprovalAgent🔒 Tool Approval RequiredTool: execute_commandReply yes/norequest_approval(tool, args)Post Block Kit messageUser replies “yes”Update message ✅ ApprovedApprovalDecision(approved=True)

Discord

python
from praisonaiagents import Agent
from praisonai.bots import DiscordApproval

agent = Agent(
    name="assistant",
    instructions="Help users with system tasks",
    tools=["execute_command"],
    approval=DiscordApproval(channel_id="YOUR_CHANNEL_ID"),
)
agent.start("Delete old log files")
ParameterDefaultDescription
tokenDISCORD_BOT_TOKEN envDiscord bot token
channel_id_(required)_Channel ID to send approvals to
timeout300 (5 min)Seconds to wait for response
poll_interval3.0Seconds between polls

Telegram

python
from praisonaiagents import Agent
from praisonai.bots import TelegramApproval

agent = Agent(
    name="assistant",
    instructions="Help users with system tasks",
    tools=["execute_command"],
    approval=TelegramApproval(chat_id="YOUR_CHAT_ID"),
)
agent.start("Delete old log files")
ParameterDefaultDescription
tokenTELEGRAM_BOT_TOKEN envTelegram bot token
chat_id_(required)_Chat ID to send approvals to
timeout300 (5 min)Seconds to wait for response
poll_interval2.0Seconds between polls
Diagram
TelegramTelegramApprovalAgentTelegramTelegramApprovalAgent🔒 Tool Approval Required✅ Approve ❌ Denyrequest_approval(tool, args)sendMessage + InlineKeyboardcallback_query “approve”editMessageText ✅ ApprovedApprovalDecision(approved=True)

Webhook

python
from praisonaiagents import Agent
from praisonai.bots import WebhookApproval

agent = Agent(
    name="assistant",
    tools=["execute_command"],
    approval=WebhookApproval(
        webhook_url="https://your-app.com/api/approvals",
        headers={"Authorization": "Bearer sk-xxx"},
    ),
)
ParameterDefaultDescription
webhook_urlAPPROVAL_WEBHOOK_URL envURL to POST requests to
status_urlwebhook_url/{request_id}URL template for polling
headers{}Extra HTTP headers (e.g. auth)
timeout300 (5 min)Seconds to wait
poll_interval5.0Seconds between polls

HTTP Dashboard

python
from praisonaiagents import Agent
from praisonai.bots import HTTPApproval

agent = Agent(
    name="assistant",
    tools=["execute_command"],
    approval=HTTPApproval(host="127.0.0.1", port=8899),
)
# Open http://127.0.0.1:8899/approve/<request_id> in your browser
ParameterDefaultDescription
host127.0.0.1Bind address
port8899Port to listen on
timeout300 (5 min)Seconds to wait for response

Agent

python
from praisonaiagents import Agent
from praisonaiagents.approval import AgentApproval

reviewer = Agent(
    name="security-reviewer",
    instructions="Only approve low-risk read operations. Deny anything destructive.",
)

worker = Agent(
    name="assistant",
    tools=["execute_command"],
    approval=AgentApproval(approver_agent=reviewer),
)
ParameterDefaultDescription
approver_agentAuto-createdAgent instance to evaluate requests
llmgpt-4o-miniLLM for default approver agent

Approval Keywords

All messaging backends (Slack, Discord, Telegram) understand these keywords:

ActionKeywords
Approveyes, y, approve, approved, ok, allow, go, proceed, confirm
Denyno, n, deny, denied, reject, block, stop, cancel, refuse

How It Works

Diagram
RegistryBackendAgentRegistryBackendAgentalt[Fast path][Needs backend]alt[Agent has approval backend][No agent backend (fallback)]Check self._approval_backendrequest_approval(ApprovalRequest)ApprovalDecisionapprove_sync(agent_name, tool, args)Check: required? env? yaml? already?ApprovalDecision(approved=True)request_approval(ApprovalRequest)ApprovalDecisionApprovalDecision
StepWhat Happens
Agent backendapproval=True or custom backend on the Agent is checked first
Required?Only tools in the dangerous-tools set need approval
Env checkPRAISONAI_AUTO_APPROVE=true skips all prompts
YAML checkTools listed in YAML approve field are auto-approved
Already approvedOnce approved in a session, no re-prompt
BackendConsoleBackend (default), AutoApproveBackend, or your custom

Configuration Options

Agent Parameter (Recommended)

ValueBehavior
approval=TrueAuto-approve all dangerous tools for this agent
approval=False / NoneUse registry fallback (default: console prompt)
approval=SlackApproval(...)Route approvals to Slack
approval=TelegramApproval(...)Route approvals to Telegram
approval=DiscordApproval(...)Route approvals to Discord

Other Methods

MethodScopeUse Case
PRAISONAI_AUTO_APPROVE=trueAll agentsCI/CD, testing
get_approval_registry().set_backend(backend)All agentsGlobal policy
get_approval_registry().set_backend(backend, agent_name="x")Single agentRegistry-level control
YAML approve: [tool1, tool2]Per-taskDeclarative configs

Multi-Agent Example

Different agents can have different approval policies:

python
from praisonaiagents import Agent
from praisonaiagents.approval import AgentApproval
from praisonai.bots import SlackApproval, TelegramApproval

# Bot agent: auto-approve everything
bot = Agent(name="bot", approval=True)

# Interactive: console prompt (default)
interactive = Agent(name="interactive")

# Critical ops: approved via Slack
deployer = Agent(
    name="deployer",
    approval=SlackApproval(channel="#deploy-approvals"),
)

# Data ops: approved via Telegram
data_agent = Agent(
    name="data-processor",
    approval=TelegramApproval(chat_id="123456"),
)

# AI-reviewed: no human needed
reviewer = Agent(name="reviewer", instructions="Only approve safe read operations")
ai_agent = Agent(name="ai-reviewed", approval=AgentApproval(approver_agent=reviewer))

Dangerous Tools (Default)

These tools require approval by default:

ToolRisk Level
execute_commandcritical
kill_processcritical
execute_codecritical
write_filehigh
delete_filehigh
move_filehigh
execute_queryhigh
crawlmedium
scrape_pagemedium

Add or remove requirements:

python
from praisonaiagents.approval import get_approval_registry

registry = get_approval_registry()
registry.add_requirement("my_dangerous_tool", risk_level="high")
registry.remove_requirement("crawl")

Best Practices

Use approval=True for bot agents

Set approval=True directly on agent constructors for unattended bots. This is the simplest, most agent-centric approach.

Use –approval slack for team oversight

Route dangerous tool approvals to a shared Slack channel so your team can review and approve in real time. Works across timezones — the agent waits up to 5 minutes by default.

Cross-platform: Telegram bot → Slack approval

Users can chat with your agent via Telegram while dangerous tool approvals are routed to a Slack admin channel. Just set approval=SlackApproval(...) on the agent powering the Telegram bot.

Use environment variable for CI/CD

Set PRAISONAI_AUTO_APPROVE=true in your CI environment to avoid blocking on prompts during automated testing.

Use per-agent backends for multi-agent systems

Different agents may need different approval policies. Pass different backends to each agent’s approval= parameter.


Related