Skip to main content

Introduction

The Osmium Chat Protocol messaging system provides a comprehensive set of features for sending, editing, searching, and managing messages across different chat types. Messages can be sent to users, groups, channels, or yourself (saved messages).

Message Structure

Messages in Osmium follow a well-defined structure that supports rich content, media attachments, and formatting:
message Message {
  refs.ChatRef chat_ref = 1;
  fixed64 message_id = 2;        // @snowflake<Message>
  fixed64 author_id = 3;         // @snowflake<User>
  string message = 4;
  optional fixed64 reply_to = 5; // @snowflake<Message>
  repeated media.MessageMedia media = 6;
  repeated MessageEntity entities = 7;
  optional uint64 edited_at = 8;
  optional MessageType type = 9;
  optional MessageForwardInfo forward = 10;
}

Message Types

Messages can have different types to represent various events:
  • UNKNOWN (0) - Default message type for text messages
  • CALL (1) - Voice or video call message
  • JOIN (2) - User joined the chat
  • LEAVE (3) - User left the chat

Chat References

All messaging operations require a ChatRef to specify the target chat. A ChatRef can point to:
message ChatRef {
  oneof ref {
    UserRef user = 1;           // Direct message to a user
    ChannelRef channel = 2;     // Message in a community channel
    GroupRef group = 3;         // Message in a group chat
    RefSelf self = 4;           // Saved messages (message to yourself)
  }
}

UserRef

For direct messages to a specific user:
message UserRef {
  fixed64 user_id = 1;  // @snowflake<User>
}

ChannelRef

For messages in a community channel:
message ChannelRef {
  fixed64 community_id = 1;  // @snowflake<Community>
  fixed64 channel_id = 2;    // @snowflake<Channel>
}

GroupRef

For messages in a group chat:
message GroupRef {
  fixed64 group_id = 1;  // @snowflake<Chat>
}

RefSelf

For saved messages (messages to yourself):
message RefSelf {}

Message Operations

The messaging system supports the following operations:

Snowflake IDs

All message IDs, user IDs, and chat IDs use snowflake identifiers (fixed64). Snowflakes are 64-bit integers that encode timestamp information and are sortable by creation time.

Build docs developers (and LLMs) love