Skip to main content
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.
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")

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

# 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

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:
# 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

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

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
Users can reply with richer text like “yes, but change the path to ~/Downloads”. The backend uses an LLM to classify intent and extract modified arguments — the tool runs with the updated values.

How It Works

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

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:
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:
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

Set approval=True directly on agent constructors for unattended bots. This is the simplest, most agent-centric approach.
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.
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.
Set PRAISONAI_AUTO_APPROVE=true in your CI environment to avoid blocking on prompts during automated testing.
Different agents may need different approval policies. Pass different backends to each agent’s approval= parameter.