Skip to main content
Use create_event_router when a LangGraph agent wants Aion to dispatch normalized Aion events to handler functions without hiding graph topology. The helper returns a normal LangGraph node. Add it with builder.add_node(...) and connect it with ordinary LangGraph edges.

Overview

The event router owns only the internal event-to-handler dispatch. The graph author owns all incoming and outgoing edges.

Registrations

Dispatch order for each invocation:
  1. Kind-specific handler (on_message, on_reaction, on_command, on_card_action) if registered for the event kind.
  2. on_event — if no kind-specific handler matches but an Aion event is present.
  3. on_invoke — if there is no Aion event, or neither a kind-specific handler nor on_event is registered.

Handler Injection

Handlers may declare only the parameters they need:
Available injected parameters: Any other declared parameter is forwarded to LangGraph for native injection, such as config, store, or writer.

Explicit Entry Routing

Because the event router is a normal node, you can place your own node before it. This is useful for agents that need to route daemon-style requests, reject unsupported runtime contexts, or validate distribution metadata before event dispatch.

Dispatch Rules

The dispatch surface is based on normalized event kinds, not provider-specific trigger names. That means:
  • a Slack mention and a Telegram DM can both normalize to on_message
  • a slash command can normalize to on_command
  • a card button click can normalize to on_card_action
If an author needs provider-specific behavior, they should inspect context.event, distribution, or inbox, not register provider-only handler names.