Messages

Messages are the most convenient way for users to reach out and discuss.

Simply create a message referencing an asset as follows:

stelace.messages.create({
  topicId: 'ast_2l7fQps1I3a1gJYz2I3a', // asset ID
  content: 'Hi, how are you?',
  receiverId: 'usr_WHlfQps1I3a1gJYz2I3a'
})

When the receiver gets the message, it can be marked as read:

stelace.messages.update('msg_Vuz9KRs10NK1gAHrp0NK', {
  read: true
})

Conversation

Stelace introduces the concept of conversation to group messages belonging to the same discussion.

A conversationId is automatically assigned to a message when it isn’t provided, so you can reuse it to link a message to previous ones.

stelace.messages.create({
  topicId: 'ast_2l7fQps1I3a1gJYz2I3a', // asset ID
  content: 'Fine, and you?',
  receiverId: 'usr_xC3ZlGs1Jo71gb2G0Jo7',
  conversationId: 'conv_4FqUqs1zln1h9gZhzln' // conversation ID from the previous message
})

Messages retrieval

You can retrieve messages from a specific user with:

stelace.messages.list({
  receiverId: 'usr_WHlfQps1I3a1gJYz2I3a'
})

To retrieve messages from a conversation, you can request:

stelace.messages.list({
  conversationId: 'conv_4FqUqs1zln1h9gZhzln'
})