Page History
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
POST /v1/chat.sendMessage HTTP/1.1 Host: api.flock.co Content-Type: application/x-www-form-urlencoded Content-Length: 70 to=u:513a9f4ae409<user>&text=hello&token=632542db-1a23-4e06-8b39-01f8b0868d57<bot token> |
To receive a message, listen for the chat.receiveMessage event on your event listener URL.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
{ "name": "chat.receiveMessage", "message": { "from": "<sender identifier>u:<user>", "to": "<bot identifier>u:<bot>", "text": "<message text>hello" } } |
Can a Bot join a
...
No.
channel and send messages to it?
Bots cannot join channels, but they can send messages to it. While calling chat.sendMessage, set to
to the channel id, and token
to the bot token.
You also need to set onBehalfOf
to the id of a user who has installed the app, is a member of the channel and has permission to post messages to it. Since bots cannot join channels themselves, the user whose id is provided in onBehalfOf
is used to check for channel membership and posting permissions. This means that an app's bot can only post messages to channels where at least one user who has installed the app has permission to post messages.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
POST /v1/chat.sendMessage HTTP/1.1
Host: api.flock.co
Content-Type: application/x-www-form-urlencoded
Content-Length: 70
to=g:<channel>&text=hello&token=<bot token>&onBehalfOf=u:<user> |