Skip to main content
Subscribe to gateway channels and receive real-time messages — WebSocket first, polling when blocked.
from praisonaiagents import Agent
from praisonaiagents.push import PushClient

agent = Agent(
    name="alerts-agent",
    instructions="Summarise incoming alert events in one sentence",
)

client = PushClient("ws://localhost:8765/ws", auth_token="my-token")
await client.connect()

@client.on("channel_message")
async def on_msg(msg):
    print(agent.start(f"Summarise: {msg.data}"))

await client.subscribe("alerts")
await client.wait_closed()
The user subscribes to a channel; push events arrive over WebSocket and the agent summarises each message.
PushClient ships in the praisonai wrapper (pip install praisonai). Core praisonaiagents.push exports protocols and ChannelMessage only.

How It Works

Quick Start

1

Simple Usage

Connect and subscribe:
from praisonaiagents.push import PushClient

client = PushClient("ws://localhost:8765/ws", auth_token="my-token")
await client.connect()

@client.on("channel_message")
async def on_message(msg):
    print(f"{msg.channel}: {msg.data}")

await client.subscribe("alerts")
await client.wait_closed()
2

With Configuration

Enable push on the gateway:
from praisonaiagents import GatewayConfig
from praisonaiagents.gateway import PushConfig

config = GatewayConfig(push=PushConfig(enabled=True))

How It Works

ComponentPurpose
PushClientAuto-reconnect, transport fallback
WebSocketTransportPrimary real-time transport
PollingTransportFallback for restricted networks
ChannelsNamed pub/sub streams
PushConfigOpt-in gateway toggle (off by default)
Import paths:
from praisonai.push import PushClient                    # wrapper (recommended)
from praisonaiagents.push import PushClient              # lazy re-export
from praisonaiagents.push import ChannelMessage          # core dataclass

Configuration Options

PushConfig

OptionTypeDefaultDescription
enabledboolFalseFeature toggle
redisRedisConfigNoneCross-server scaling
presencePresenceConfigPresenceConfig()Online/offline tracking
deliveryDeliveryConfigDeliveryConfig()ACK and retry settings
pollingPollingConfigPollingConfig()Long-poll fallback

DeliveryConfig

OptionTypeDefaultDescription
enabledboolTrueDelivery guarantees
ack_timeoutint30Seconds to wait for ACK
max_retriesint3Retry attempts
store_backendstr"memory""memory" or "redis"

Best Practices

Without Redis, channels exist on one gateway instance only.
PushConfig(enabled=False) adds zero overhead — enable only when clients subscribe.
Set fallback_to_polling=True on PushClient when WebSocket is blocked.
Real-time channels differ from A2A task webhooks — use the right page for your pattern.

Gateway

Host push channels on the gateway

A2A Push Notifications

Webhook-based task updates