There is a message_id, a unique identifier associated with every message.
This can be obtained from the following ways -
Whenever you send a message, you get the API response with the message_id as below -
const conversation = /await/ client.channel(‘messaging’, {
members: [‘Seetha’,’Lakshmi’],
channel_name: ‘Private channel’
});
const creation = /await/ conversation.create();
const message1 = /await/ conversation.sendMessage({
text: ‘One on On channel’ + userID,
mentioned_users: [‘Seetha’, ‘Lakshmi’],
silent: true,
anotherCustomField: 123
});
console.log(message1)
API response -
{
message: {
id: 'efec36da-042b-4333-a807-c5e2e056f2e5',
text: 'One on On channelLakshmi',
html: '<p>One on On channelLakshmi</p>\n',
type: 'regular',
user: {
id: 'Lakshmi',
role: 'admin',
created_at: '2020-09-16T05:08:11.574631Z',
updated_at: '2021-01-20T00:46:05.549504Z',
last_active: '2021-01-20T00:46:05.549504Z',
banned: false,
online: true,
image: 'https://getstream.io/random_svg/?name=adminuser'
},
attachments: [],
latest_reactions: [],
own_reactions: [],
reaction_counts: null,
reaction_scores: {},
reply_count: 0,
cid: 'messaging:!members-hSUVG40y536k9ymCnlS9dxIopy-mZKHcolJyc1I7doo',
created_at: '2021-01-20T00:57:44.859177Z',
updated_at: '2021-01-20T00:57:44.859177Z',
shadowed: false,
mentioned_users: [ [Object], [Object] ],
silent: true,
pinned: false,
pinned_at: null,
pinned_by: null,
pin_expires: null,
anotherCustomField: 123
},
duration: '17.72ms'
}
You can also choose to fetch the message_id from the Channel’s state where all the messages can be found.
const query_info = /await/ client.queryChannels({ channel_name: ‘Private channel’ });
console.log(query_info[0].state.messages)
You can also search for a message and get its message_id as below -
const filters = { members: { $in: [‘Seetha’] } };
const search = /await/ client.search(
filters,
‘One on On channelLakshmi’,
{ limit: 2, offset: 0 },
);
console.log(search.results[0].message.id)
Comments
0 comments
Please sign in to leave a comment.