Slack Integration with REST API
Create a bot API key
Each bot needs its own API key for tracking.
Create a bot to get an API key.
Integrate the REST API
There are three integration points as outlined below.
1. When you first connect Slack via rtm.start
When you first connect Slack via rtm.start, POST the data that Slack returns to the following endpoint.
https://tracker.dashbot.io/track?platform=slack&v=11.1.0-rest&type=connect&apiKey=<strong>API_KEY_HERE</strong>
Make sure to set the ‘Content-Type’ header to ‘application/json’
The data to POST should pass the following data:
{"self": {"...": "..."},"team": {"...": "..."},"channels": {"...": "..."},"users": {"...": "..."}}
Sample cURL
curl -X POST -H "Content-Type: application/json"-d '{"self":{"...":"..."},"team":{"...":"..."},"channels":{"...":"..."},"users":{"...":"..."}}''https://tracker.dashbot.io/track?platform=slack&v=11.1.0-rest&type=connect&apiKey=API_KEY_HERE'
2. When you receive a message on the Slack websocket
When you receive a message on the Slack websocket, POST to Dashbot passing token, botId, teamId, teamName, and message.
https://tracker.dashbot.io/track?platform=slack&v=11.1.0-rest&type=incoming&apiKey=API_KEY_HERE
Make sure to set the ‘Content-Type’ header to ‘application/json’
The data to POST should pass the following data:
{"token": "...","team": {"id": "T0RKXFPTP","name": "jessetest"},"bot": {"id": "U16R8L1JA"},"message": {"type": "message","channel": "D16RSST6W","user": "U0RKX8RDM","text": "hi, bot","ts": "1483257600.000000","team": "T0RKXFPTP"}}
Sample cURL
curl -X POST -H "Content-Type: application/json"-d '{"token":"...","team":{"id":"T0RKXFPTP","name":"jessetest"},"bot":{"id":"U16R8L1JA"},"message":{"type":"message","channel":"D16RSST6W","user":"U0RKX8RDM","text":"hi, bot","ts":"1483257600.000000","team":"T0RKXFPTP"}}''https://tracker.dashbot.io/track?platform=slack&v=11.1.0-rest&type=incoming&apiKey=API_KEY_HERE'
Note
This is just an example — we accept any rich media that Slack accepts.
3. When you send a message to Slack via the websocket or the chat.postMessage endpoint
When you send a message to Slack via the websocket or the chat.postMessage endpoint POST it to Dashbot passing token, botId, teamId, teamName, and message.
https://tracker.dashbot.io/track?platform=slack&v=11.1.0-rest&type=outgoing&apiKey=API_KEY_HERE
Make sure to set the ‘Content-Type’ header to ‘application/json’
The data to POST should pass the following data:
{"token": "...","team": {"id": "T0RKXFPTP","name": "jessetest"},"bot": {"id": "U16R8L1JA"},"message": {"type": "message","text": "Hello, my human pet","channel": "D16RSST6W"}}
Sample cURL
curl -X POST -H "Content-Type: application/json"-d '{"token":"...","team":{"id":"T0RKXFPTP","name":"jessetest"},"bot":{"id":"U16R8L1JA"},"message":{"type":"message","text":"Hello, my human pet","channel":"D16RSST6W"}}''https://tracker.dashbot.io/track?platform=slack&v=11.1.0-rest&type=outgoing&apiKey=API_KEY_HERE'
Note
This is just an example — we accept any rich media that Slack accepts.
Example
View a complete example.
Extra integrations when using Slack buttons
When you receive a button click message on Slack webhook
When you receive a message on Slack webhook, send the payload to Dashbot. Make sure to parse the payload as JSON and do not send a raw string.
https://tracker.dashbot.io/track?platform=slack&v=11.1.0-rest&type=incoming&apiKey=API_KEY_HERE
Make sure to set the ‘Content-Type’ header to ‘application/json’
The data to POST should pass the following data:
{"token": "...","team": {"id": "T0RKXFPTP","name": "jessetest"},"bot": {"id": "U16R8L1JA"},"message": {"actions": [{"name": "name","value": "value"}],"callback_id": "foo_1474051104627","team": {"id": "T0RKXFPTP","domain": "jessetestteam"},"channel": {"id": "D0S2AS2F4","name": "directmessage"},"user": {"id": "U0RKX8RDM","name": "jhull"},"action_ts": "1483344000000.000000","message_ts": "1483344000000.000000","attachment_id": "1","token": "...","original_message": {"...": "..."}},"response_url": "..."}
Sample cURL
curl -X POST -H "Content-Type: application/json"-d '{"token":"...","team":{"id":"T0RKXFPTP","name":"jessetest"},"bot":{"id":"U16R8L1JA"},"message":{"actions":[{"name":"name","value":"value"}],"callback_id":"foo_1474051104627","team":{"id":"T0RKXFPTP","domain":"jessetestteam"},"channel":{"id":"D0S2AS2F4","name":"directmessage"},"user":{"id":"U0RKX8RDM","name":"jhull"},"action_ts":"1483344000000.000000","message_ts":"1483344000000.000000","attachment_id":"1","token":"...","original_message":{"...":"..."}},"response_url":"..."}''https://tracker.dashbot.io/track?platform=slack&v=11.1.0-rest&type=incoming&apiKey=API_KEY_HERE'
Note
This is just an example — we accept any rich media that Slack accepts.
When you send a message in response to a button click
When you send a message in response to a button click, send the message to Dashbot. Be sure to set the channel.
https://tracker.dashbot.io/track?platform=slack&v=11.1.0-rest&type=outgoing&apiKey=API_KEY_HERE
Make sure to set the ‘Content-Type’ header to ‘application/json’
The data to POST should pass the following data:
{"token": "...","team": {"id": "T0RKXFPTP","name": "jessetest"},"bot": {"id": "U16R8L1JA"},"message": {"text": "replace button with this","channel": "D0S2AS2F4"}}
Sample cURL
curl -X POST -H "Content-Type: application/json"-d '{"token":"...","team":{"id":"T0RKXFPTP","name":"jessetest"},"bot":{"id":"U16R8L1JA"},"message":{"text":"replace button with this","channel":"D0S2AS2F4"}}''https://tracker.dashbot.io/track?platform=slack&v=11.1.0-rest&type=outgoing&apiKey=API_KEY_HERE'
Example
View a complete example.