Advanced topics

Advanced topics and features of the messaging module

This page describes advanced usage of our Messaging Core module with options about Conversation creation and management.

Lazy conversation creation

If you want, you can also opt for a lazy conversation creation (i.e. delaying the creation of the conversation until it's necessary) by using createDraftConversation(..). You can notice it is not a suspend function as it makes no network call.

Draft conversations are local on-device and will not be effectively created on Console-side until the patient successfully sends their first message. This way, you can avoid having meaningless empty conversations.

Since createDraftConversation(..) does contain a success callback with a ConversationId just like createConversation(..), you can seamlessly use the returned id as argument for operations like watchItemsOfConversation(..) or sendMessage(..).

Conversation creation options

Set a title

You can add a title when calling createConversation or createDraftConversation.

This title is a string that will be visible to both the Patient and the Providers on the Console so make sure you use it carefully.

📘

Note that this title is editable by Providers from the Console, just like they can add a title to a Conversation that doesn't have one already.

Automatically add Providers to a Conversation

When calling createConversation or createDraftConversation you have access to a parameter named providerIds that is a nullable string[].

By specifying an array with one or more properly formatted Providers UUID you can automatically add them to the Conversation when created.

📘

For security reasons, you cannot query existing Provider UUIDs from the patient SDK, this is something only your server can access and that it needs to send to your app.

Send a first message on Patient's behalf

When calling createConversation you can pass a MessageInput to the initialMessage parameter that will be sent on behalf of the Patient when creating the conversation.

This is useful if you want to automatically create a Conversation with some data you want your Providers to be aware of.

See the Core module documentation for details about what a MessageInput can contain.