API Update: New Field in API Responses

Slack API
Slack Platform Blog
2 min readApr 13, 2016

As the developer of a Slack app, you can have your app post a message as a user. The message will have the user’s name and avatar, and for all intents and purposes, be a message from the user. There are some very good uses for this, but it can also be confusing and misleading. We’re making a change to help alleviate that potential confusion.

Soon — but no earlier than Wednesday, April 20 — we will add a bot_id field to messages that are posted by apps on behalf of users. Now a message posted with as_user:true may have both a user ID and a bot ID, which will allow clients to label messages clearly as coming from a user, but through an app or bot. This change will apply to all messages going forward, but will not be retroactively added to historical messages.

Note that bot_id in these responses will refer to the specific instance of the app that is returning the response. It is not a reference to a bot user’s ID or the canonical ID of the app.

What you will see is that messages returned via APIs like channels.history, groups.history, im.history, chat.postMessage and chat.update may contain both bot_id and user fields. If you have a bot user, you can use this newly added bot_id to find which app the messages are coming from — for example, by matching the bot_id to the data you get during rtm.start.

Let’s quickly review how this change will impact our responses to methods returning “message” objects.

When you call channels.history, you may start seeing both bot_id and user fields for messages in response:

{
"ok": true,
"latest": "1358547726.000003",
"messages": [
{
"type": "message",
"ts": "1358546515.000008",
"user": "U2147483896",
"text": "Hello",
"bot_id": "B065FDFLY",
},
...
]
}

Similarly, when you post a message on behalf of a user, your new response would look like below.

{
"ok": true,
"channel": "C061GA5JL",
"ts": "1459880609.085563",
"message": {
"type": "message",
"user": "U061H1BMX",
"text": "Hello World",
"bot_id": "B065FDFLY",
"ts": "1459880609.085563"
}
}

To find out the app that generated this message, using a bot token, you can query rtm.start and receive a response like below with bot_id details.

{
"ok": true,
"url": "wss:\/\/ms9.slack-msgs.com\/websocket\/7I5yBpcvk",
"self": {...},
"team": {...},
"users": [...],
...
"bots": [
{
"id": "B061VC15F",
"deleted": false,
"name": "demo app",
"icons": {...}
},
...
]
}

This additional bot_id field should not negatively impact your applications and integrations, but please let us know if you anticipate issues parsing these responses. Send a note to feedback@slack.com with the details and we’ll look into it. Follow @SlackAPI on Twitter and the #changelog to stay informed.

--

--

Slack API
Slack Platform Blog

Tips to integrate with Slack APIs to make your work life simpler, more pleasant and more productive — whether for your internal team or millions of Slack users.