Twilio Conversations is a highly customizable and flexible product with powerful features, like cross-channel messaging and group texting. We've learned a lot from our customers, and this guide provides some known best practices to make implementation easier and reliable.
The Conversations client-side SDKs (JavaScript, Android, and iOS) operate by sending commands to the backend and by receiving updates from the backend over an independent channel, such as SMS, WhatsApp, or chat. This means that most asynchronous operations require you to asynchronously wait for an update event before you can see actual updated values on the front end.
The Conversations client-side SDKs receive event-based updates regularly and need to be connected to the internet to function correctly. For a reasonable user experience, clients should have a minimum network bandwidth of 100kbps with lower than 200ms latency.
Here are some additional details about the JavaScript SDK behavior:
Client#conversationAdded
event, and only after that, call the getSubscribedConversations
method.
getSubscribedConversations
is paginated. Hence, duplicated Conversations might arrive from two sources: from events and from this method call, it is up to the developer to resolve this duplication.getSubscribedConversations
method, the pagination is set to 100 items per page.Conversation#messageAdded
event is emitted on new Messages.
Conversation#messageUpdated
and Conversation#messageRemoved
events are emitted only on those fetched messages.Conversation.getParticipantCount()
Conversation.getMessagesCount()
Conversation.getUnreadMessagesCount()
The following practices apply to Android and iOS SDKs.
ConversationsClient
operations only after the client has fully synchronized (you should have received the ConversationsClient.onClientSynchronization
callback with status equivalent to .ALL → this means the synchronization operation has completed).ConversationsClient
.