Bot Typing Indicators

Show a typing indicator while the agent is working, with keepalive and circuit breaker

Typing indicators tell users the bot is working — with automatic keepalive resends, a circuit breaker on failures, and a safety TTL so a stuck indicator never hangs forever.

python
from praisonaiagents import Agent

agent = Agent(name="assistant", instructions="You are a helpful assistant.")
agent.start("Look up today weather for London.")

The user sends a message; a typing indicator shows while the agent works, with keepalive and automatic timeout.

Diagram

Agent Run Start

TypingManager

Keepalive Resend

Circuit Breaker

Safety TTL

Channel API

Quick Start

  1. Enable typing on a Telegram bot
    python
    from praisonaiagents import Agent
    from praisonai.bots import TelegramBot
    
    agent = Agent(name="assistant", instructions="Helpful assistant")
    bot = TelegramBot(token="...", agent=agent, typing_indicator=True)
    bot.start()
  2. Use as async context manager
    python
    async with bot.typing_manager(channel_id="123456"):
        result = await agent.astart("Long research task")

    The indicator starts on entry and stops on exit — even if the agent raises an error.

How It Works

A user sends a message, the indicator appears while the agent works, and stops once the reply is sent.

Diagram
ChannelTypingManagerAgentUserChannelTypingManagerAgentUserloop[Every keepaliveinterval]Send messageRun startedShow typingResend typingRun finishedStop typingReply

TypingManager checks capabilities["typing"] before sending. On supported channels (Telegram, Discord):

  1. Sends typing action when the agent run starts
  2. Resends on a keepalive interval to prevent expiry
  3. Opens a circuit breaker after consecutive failures
  4. Enforces a safety TTL so typing never persists indefinitely

Slack, WhatsApp, and Email skip typing automatically (typing=False).

Best Practices

Combine with status reactions for rich feedback

Reactions show state on the user’s message; typing shows activity in the input area.

Pair with streaming replies on Telegram

Streaming reduces the need for typing on long answers — use both for tool-heavy agents.

Trust the safety TTL in production

The TTL prevents stuck typing indicators if a run hangs or the channel API fails silently.

Related