app.messages as a tuple containing a Space and a Message. The space is already bound to the originating conversation — you don’t need to resolve it yourself to reply.
Receiving messages
The Message shape
Every message conforms to Message.Message
Message
Narrowing content
Content is a discriminated union. Narrow onmessage.content.type before accessing fields:
"effect" (an iMessage screen effect wrapping inner content) appear on messages you sent and are echoed by the platform; see iMessage for the builder.
Group-management events (rename, avatar, addMember, removeMember, leaveSpace) arrive with message.sender set to the acting user — or undefined when the platform recorded no actor — so narrow with message.sender?.id. The agent’s own actions (e.g. space.add(...)) are not echoed back.
read is the other bidirectional arm: inbound, it means someone read a message you sent, with message.sender the reader and content.target your message. See Read.
Filtering out your own messages
Every Message carries adirection. Skip outbound messages when you only want user input:
Acting on a message
Every message is its own context. You can reply, react, or send new content into the space:react and reply.