Appearance
Removing users from channels
Similar to adding users, you can remove users either by a REST API call, or via a FileMaker script in your helper file.
Removing users using a FileMaker script
The script is available in Helper file and is called API - Leave Channel. This script accepts an object with two keys users and channels.
users: it accepts a string with an user ID or an array of users IDchannels: it accepts an object with name and mode (optional) or an array of objects, with the same shape.
Examples
{
"users": "USER_ID",
"channels":
{
"name": "channel1",
"mode": "ignore"
}
}API: Remove User from Channel
POST https://portal.yourdomain.com/message/removeuser
You can use this method to remove one or more users from channels. You must pass the API key generated for your app to authenticate this reqeust.
Headers
| Name | Type | Description |
|---|---|---|
| content-type | string | application/json |
| accept | string | application/json |
Request Body
| Name | Type | Description |
|---|---|---|
| apiKey | string | The API key generated for your Klai app |
| users | array | array of user/channel objects |
| users[0].id | string | Klai user id from the users table in the helper file |
| users[0].channels | array | any array of channel objects |
{
"users": [
"USER_1_ID",
"USER_2_ID"
]
}Example request body
json
{
"apiKey": "BFAPI_GENERATED-API-KEY",
"users": [
{
"id": "USER_1_ID",
"channels": [
{
"name": "channel1"
}
]
},
{
"id": "USER_2_ID",
"channels": [
{
"name": "channel1"
},
{
"name": "channel2"
}
]
}
]
}Notes
- The REST endpoint expects
usersto be an array of objects. - Each object contains the user
idplus thechannelsto remove for that user. - This differs from the helper-file script shape earlier on this page, which accepts top-level
usersandchannelskeys separately.
Leaving Anonymous Channels
Users can only be removed from anonymous channels directly from the browser. The current browser tab that executes the action will be the one removed from the channel.
A user can be removed from an anonymous channel via a Klai action called channelLeaveAnon.
Example:
{
"action": "channelLeaveAnon",
"options": {
"channel": "anonymousChatRoom"
}
}Learn more: