Manage conversations
Learn how to mute, pin, archive and label WhatsApp conversations using Unipile API.
Mute a conversation
To update the mute status of a chat, use Update a Chat method and define muted_until to:
- The date until which the chat should be muted
trueto mute indefinitelyfalseto unmute
const { data, error } = await messagingApi.updateChat({
path: {
account_id: "acc_123456789",
chat_id: "chat_id",
},
body: {
muted_until: true,
},
});messaging_api.update_chat(
"chat_id",
"acc_123456789",
{"muted_until": True},
)curl --request PATCH \
--url https://api.unipile.com/v2/account_id/chats/chat_id \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{"muted_until":true}'
Note on message events
message.newevents are always sent to webhooks — even for muted chats — as they are intended for message synchronization.If your application includes a notification feature that should respect a chat’s mute status, check the mute status of the parent chat for each incoming message on your webhook before deciding whether to trigger a notification for your users.
Pin a conversation
To pin a conversation at the top of the list of chats, use Update a Chat method and define pin_status to true. Set to false to unpin it.
const { data, error } = await messagingApi.updateChat({
path: {
account_id: "acc_123456789",
chat_id: "chat_id",
},
body: {
pin_status: true,
},
});messaging_api.update_chat(
"chat_id",
"acc_123456789",
{"pin_status": True},
)curl --request PATCH \
--url https://api.unipile.com/v2/account_id/chats/chat_id \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{"pin_status":true}'Archive a conversation
To move a conversation into the Archived section, use Update a Chat method and define archive_status to true. Set to false to remove a chat from the archived section.
const { data, error } = await messagingApi.updateChat({
path: {
account_id: "acc_123456789",
chat_id: "chat_id",
},
body: {
archive_status: true,
},
});messaging_api.update_chat(
"chat_id",
"acc_123456789",
{"archive_status": True},
)curl --request PATCH \
--url https://api.unipile.com/v2/account_id/chats/chat_id \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{"archive_status":true}'Set label on a conversation
On WhatsApp for Business only, you can set labels on chats using Update a Chat method with the label field. Labels must be created on the WhatsApp application before as Unipile does not support creating labels through the API. Make sure to respect the case of the label name.
const { data, error } = await messagingApi.updateChat({
path: {
account_id: "acc_123456789",
chat_id: "chat_id",
},
body: {
label: "Personal",
},
});messaging_api.update_chat(
"chat_id",
"acc_123456789",
{"label": "Personal"},
)curl --request PATCH \
--url https://api.unipile.com/v2/account_id/chats/chat_id \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{"label":"Personal"}'Updated about 1 month ago