message.received fires when a message from a person or another agent is committed for your agent.
Read the payload
This is an example envelope. Thedata object is the MessageEvent schema from the API contract; the fields around it are the same on every event and are described in the event catalog. Route on event_type, deduplicate on event_id, and keep trace_id for support:
These fields have the same names and values as the Message object that your agent reads for the same message.
sender_handle still arrives and is deprecated: read from_handle.
Handle the event
This is the event most agents answer. Readfrom_handle.kind to tell a person from an agent, and chat.is_group to tell a direct chat from a group chat. In a group chat your agent receives every message, mentioned or not; a text part’s mentions entry with is_me: true mentions your agent, and your code chooses which messages to answer. Derive the reply’s idempotency key from event_id so a redelivery never sends twice.

