Jido.Chat.Message (Jido Chat v1.0.0)

Copy Markdown View Source

Chat SDK-style normalized message model.

Summary

Functions

Creates a normalized message from canonical incoming payload.

Builds a message from serialized map data.

Creates a normalized message from map input.

Returns the Zoi schema for Message.

Serializes the message into a plain map with a revivable type marker.

Types

t()

@type t() :: %Jido.Chat.Message{
  attachments: [
    %Jido.Chat.Media{
      duration: term(),
      filename: term(),
      height: term(),
      kind: term(),
      media_type: term(),
      metadata: term(),
      size_bytes: term(),
      url: term(),
      width: term()
    }
  ],
  author:
    nil
    | nil
    | %Jido.Chat.Author{
        full_name: term(),
        is_bot: term(),
        is_me: term(),
        metadata: term(),
        user_id: term(),
        user_name: term()
      },
  channel_id: nil | nil | binary(),
  created_at: nil | nil | any(),
  external_message_id: nil | nil | binary(),
  external_room_id: nil | nil | any(),
  formatted: nil | nil | binary(),
  id: binary(),
  is_mention: boolean(),
  metadata: map(),
  raw: nil | nil | any(),
  text: nil | nil | binary(),
  thread_id: nil | nil | binary(),
  updated_at: nil | nil | any()
}

Functions

from_incoming(incoming, opts \\ [])

@spec from_incoming(
  Jido.Chat.Incoming.t(),
  keyword()
) :: t()

Creates a normalized message from canonical incoming payload.

from_map(map)

@spec from_map(map()) :: t()

Builds a message from serialized map data.

new(attrs)

Creates a normalized message from map input.

schema()

Returns the Zoi schema for Message.

to_map(message)

@spec to_map(t()) :: map()

Serializes the message into a plain map with a revivable type marker.