Manage groups
Learn how to create Facebook group chats and manage their participants with Unipile API.
Create a group
To create a group, use Start a Chat and pass several user IDs in users_ids. Set name to name the group.
const { data } = await messagingApi.startChat({
path: {
account_id: "acc_123456789",
},
body: {
users_ids: ["100001234567890", "100009876543210"],
name: "Project team",
text: "Welcome to the group!",
},
});chat = messaging_api.start_chat(
"acc_123456789",
{
"users_ids": ["100001234567890", "100009876543210"],
"name": "Project team",
"text": "Welcome to the group!",
},
)curl --request POST \
--url https://api.unipile.com/v2/acc_123456789/chats/send \
--header 'X-API-KEY: api-key' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"users_ids": ["100001234567890", "100009876543210"],
"name": "Project team",
"text": "Welcome to the group!"
}
'To rename a group or change its picture, use Update a Chat.
List participants
To list the participants of a group, use List all Chat Participants.
const { data } = await messagingApi.getParticipantsList({
path: {
account_id: "acc_123456789",
chat_id: "chat_id",
},
});participants = messaging_api.get_participants_list("chat_id", "acc_123456789")curl --request GET \
--url https://api.unipile.com/v2/acc_123456789/chats/chat_id/participants \
--header 'X-API-KEY: api-key' \
--header 'accept: application/json'Add a participant
To add a participant, use Add a Chat Participant.
await messagingApi.addParticipant({
path: {
account_id: "acc_123456789",
chat_id: "chat_id",
},
body: {
user_id: "user_id",
},
});messaging_api.add_participant(
"chat_id",
"acc_123456789",
{"user_id": "user_id"},
)curl --request POST \
--url https://api.unipile.com/v2/acc_123456789/chats/chat_id/participants \
--header 'X-API-KEY: api-key' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"user_id": "user_id"
}
'Remove a participant
To remove a participant, use Remove a Chat Participant.
await messagingApi.removeParticipant({
path: {
account_id: "acc_123456789",
chat_id: "chat_id",
user_id: "user_id",
},
});messaging_api.remove_participant(
"chat_id",
"user_id",
"acc_123456789",
)curl --request DELETE \
--url https://api.unipile.com/v2/acc_123456789/chats/chat_id/participants/user_id \
--header 'X-API-KEY: api-key' \
--header 'accept: application/json'Updated 16 days ago
Did this page help you?