Message Metadata Queries

Content: Message Metadata Queries

User Intent

"How do I query Slack/Teams/Discord messages by channel, author, mentions, etc.?"

Operation

  • SDK Method: queryContents() with message-specific patterns

  • GraphQL: queryContents query

  • Entity Type: Content (type: MESSAGE)

  • Common Use Cases: Find messages by channel, author queries, mentions detection, link analysis

Message Metadata Structure

Messages (from Slack, Teams, Discord) have metadata in the message field:

interface MessageMetadata {
  identifier: string;              // Message ID
  conversationIdentifier: string;  // Thread/conversation ID
  channelIdentifier: string;       // Channel ID
  channelName: string;             // Channel name
  author: PersonReference;         // Message author
  mentions: PersonReference[];     // @mentioned users
  attachmentCount: number;
  links: string[];                 // URLs in message
}

TypeScript (Canonical)

Query Patterns

1. Filter by Channel

2. Find by Author

3. Find Mentions

4. Thread/Conversation Queries

6. Messages with Attachments

7. Channel Activity Analysis

8. Collaboration Patterns

Query messages

messages = await graphlit.queryContents( filter=ContentFilterInput( types=[ContentTypes.Message] ) )

From specific feed

slack_messages = await graphlit.queryContents( filter=ContentFilterInput( types=[ContentTypes.Message], feeds=[EntityReferenceInput(id='slack-feed-id')] ) )

Access metadata

for msg in messages.contents.results: if msg.message: print(f"Channel: {msg.message.channel_name}") print(f"Author: {msg.message.author.name}") if msg.message.mentions: print(f"Mentions: {len(msg.message.mentions)}")

Developer Hints

Channel Names are Searchable

Mentions Array

Thread Detection

Common Issues & Solutions

Issue: Can't filter by specific channel in query Solution: Query all messages, filter client-side

Issue: Want to find all messages from one user to another Solution: Filter by author and mentions

Issue: Need to count messages per channel Solution: Query and aggregate

Production Example

Last updated

Was this helpful?