> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Outbound Delivery Protocol • AI Agent SDK

> OutboundDeliveryProtocol: Protocol for durable outbound message delivery.

# OutboundDeliveryProtocol

> Defined in the [**protocols**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/protocols.md) module.

AI Agent

Protocol for durable outbound message delivery.

Ensures messages sent to external channels (Telegram, Slack, Discord, etc.)
are persisted before sending and can be retried on failure. This provides
crash-safe at-least-once delivery for channel replies.

Example usage (implementation in praisonai\_bot.gateway):
from praisonai.bots import OutboundQueue

outbox = OutboundQueue(path="\~/.praisonai/state/outbox.sqlite")

# Enqueue before sending

key = await outbox.enqueue(
idempotency\_key="msg-123",
target\_channel="telegram:12345",
payload=\{"text": "Hello", "metadata": \{...}}
)

# Attempt delivery

success = await deliver\_with\_retry(adapter, channel\_id, payload)

# Mark as sent only if successful

if success:
await outbox.mark\_sent(key)

# On restart, drain pending messages

await outbox.drain(delivery\_handler)

## Methods

> [card] [enqueue()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/OutboundDeliveryProtocol-enqueue.md)
>
> Persist an outbound message for delivery.

> [card] [mark\_sent()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/OutboundDeliveryProtocol-mark_sent.md)
>
> Mark a message as successfully sent.

> [card] [mark\_failed()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/OutboundDeliveryProtocol-mark_failed.md)
>
> Mark a message as failed.

> [card] [drain()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/OutboundDeliveryProtocol-drain.md)
>
> Process pending messages.

> [card] [pending\_count()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/OutboundDeliveryProtocol-pending_count.md)
>
> Get count of pending messages awaiting delivery.

> [card] [size()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/OutboundDeliveryProtocol-size.md)
>
> Get total number of messages in queue.

> [card] [purge\_old()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/OutboundDeliveryProtocol-purge_old.md)
>
> Remove old sent messages.

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L2008)
>
> `praisonaiagents/gateway/protocols.py` at line 2008


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.