Skip to main content
Version: Next

Chats in SDKs

Get Users Conversations

This function will return all conversations which the user subscribed before.

var conversations = ServiceHub.Services.Chats.GetSubscribedConversations(new GetSubscribedConversationsParams
{
Skip = 0,
Limit = 25
});

Get Conversation Members

This function will return all members of a specific conversation.

var members = await ServiceHub.Services.Chats.GetConversationMembers(new GetConversationMembersParams
{
ConversationId = ConversationId,
Skip = 0,
Limit = 25
})

Get Conversation Messages

This function return last messages of a conversation.

var messages = ServiceHub.Services.Chats.GetConversationMessages(new GetConversationMessagesParams
{
ConversationId = 0,
Skip = 0,
Limit = 25
});

Subscribe To Conversation

This functions will subscribe user to a new group, you can create or join by specifying group details. If you provide a conversation ID it will join user to it, otherwise it will create a new one.

await ServiceHub.Services.Chats.Subscribe(new SubscribeParams
{
ConversationId = ConversationId,
ConversationName = "name of new group"
});

Unsubscribe From Conversation

This function will unsubscribe a user from a specific group by ID.

await ServiceHub.Services.Chats.Unsubscribe(new UnsubscribeParams
{
ConversationId = ConversationId
});

Send

This function will use for sending message to someone or a group, you can specify sending type in ConversationType.Private or ConversationType.Group and depends on it, target ID can be group's ID or a user ID.

await ServiceHub.Services.Chats.Send(new SendParams
{
Type = ConversationType.Private,
TargetUserId = 0,
Message = new Message
{
Type = 0,
Image = null,
Text = null,
Payload = null,
Buttons = null,
Like = 0,
Version = 0
}
});

Edit a Message

This function will edit an existing message.

await ServiceHub.Services.Chats.EditMessage(new EditMessageParams
{
ConversationId = 0,
MessageId = 0,
Message = new Message
{
Image = null,
Text = null,
Payload = null,
Buttons = null,
Like = 0,
Version = 0
}
});

Delete a Message

This function will delete an existing message.

await ServiceHub.Services.Chats.DeleteMessage(new DeleteMessageParams
{
ConversationId = 0,
MessageId = 0
});

Delete All Message of a User

This function will delete all messages in a specific group.

await ServiceHub.Services.Chats.DeleteMessage(new DeleteMessageParams
{
ConversationId = 0,
MessageId = 0
});