Botkit: Listen for File Shares in Slack

Created on 29 Mar 2017  路  3Comments  路  Source: howdyai/botkit

I didn't see it in the documentation but I'm wondering if there is a method for listening for file shares. There is a 'file_share' event listed in the Slack documentation but I'm not sure if there is anything in botkit that listens for those type of events. Something like controller.on('file_share', function(bot, message) {}) maybe?

Slack-related help wanted stale

Most helpful comment

Ah yes, I just read that piece in the docs that you can use any event not just the ones in the example :). This works great. Now I have a follow up/trickier question.

I have an interactive message setup where the user says something and they get the buttons and then after selecting one I call controller.on('interactive_message_callback'.... I would like to be able to do something where if they drop a file and share it with my bot I want to change the interactive message to include data from the file, kind of like attaching a file to an email. Is there a way I can pass the message from the controller.on('file_shared'... function over to the controller.on('interactive_message_callback'... that originally created the buttons?

All 3 comments

Under Slack Events API, Botkit triggers an event named after the message.type of the request received from Slack. This fires for Events API requests not of type message.type = 'message'.

You can listen to 'file_shared' events with the permissions files:read, I believe you will only get the file id from this event, and will have to do an api call to retrieve the actual file data.

Ah yes, I just read that piece in the docs that you can use any event not just the ones in the example :). This works great. Now I have a follow up/trickier question.

I have an interactive message setup where the user says something and they get the buttons and then after selecting one I call controller.on('interactive_message_callback'.... I would like to be able to do something where if they drop a file and share it with my bot I want to change the interactive message to include data from the file, kind of like attaching a file to an email. Is there a way I can pass the message from the controller.on('file_shared'... function over to the controller.on('interactive_message_callback'... that originally created the buttons?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings