Normalized message envelope for routing and transport.
MsgContext provides a unified, typed representation of an inbound/outbound message that can be used consistently across all pipeline stages. It contains channel identification, conversation scope, sender identity, message identification, threading context, and extensible metadata.
Usage
# Populated by Ingest pipeline
{:ok, message, msg_context} = Ingest.ingest_incoming(messaging, channel, bridge_id, incoming)
# Use for routing decisions
if msg_context.chat_type == :direct do
# Handle DM
end
# Build reply target
target = MessagingTarget.from_context(msg_context)
Summary
Functions
Creates a new MsgContext from incoming message data.
Returns the Zoi schema for MsgContext
Enriches the MsgContext with resolved internal IDs after room/participant lookup.
Types
@type t() :: %Jido.Messaging.MsgContext{ agent_mentions: [binary()], app_meta: map(), body: nil | nil | binary(), bridge_id: binary(), channel_meta: map(), channel_module: nil | nil | module(), channel_type: atom(), chat_type: :direct | :group | :channel | :thread, command: nil | nil | map(), delivery_external_room_id: nil | nil | binary(), external_message_id: nil | nil | binary(), external_reply_to_id: nil | nil | binary(), external_room_id: binary(), external_thread_id: nil | nil | binary(), external_user_id: binary(), mentions: [map()], message_id: nil | nil | binary(), participant_id: nil | nil | binary(), raw: nil | nil | map(), reply_to_id: nil | nil | binary(), room_id: nil | nil | binary(), sender_name: nil | nil | binary(), sender_username: nil | nil | binary(), thread_id: nil | nil | binary(), timestamp: nil | nil | integer(), was_mentioned: boolean() }
Functions
Creates a new MsgContext from incoming message data.
Parameters
channel_module- The channel module that received the messagebridge_id- The bridge identifierincoming- The normalized incoming message map
Examples
iex> incoming = %{
...> external_room_id: "chat_123",
...> external_user_id: "user_456",
...> text: "Hello"
...> }
iex> ctx = MsgContext.from_incoming(MyChannel, "bot_1", incoming)
iex> ctx.external_room_id
"chat_123"
Returns the Zoi schema for MsgContext
Enriches the MsgContext with resolved internal IDs after room/participant lookup.
Parameters
ctx- The MsgContext to enrichroom- The resolved Room structparticipant- The resolved Participant structmessage- The persisted Message struct