-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Send middleware - who is the bot talking to? #551
Comments
@arnthorsnaer you can look at the message.user field. Is that not working? |
Thanks for the answer @benbrown But, it does not work for me.
When I use "bot.startPrivateConversation" to send a message to the user the message object contains Additionally when I use "bot.api.chat.postMessage" then the middleware function does not execute. |
Another strange thing I noticed - when using the bot.api.chat.postMessage the controller.middleware.receive.use middleware executes (strange since I thought it only executed when the bot receives a message. Is it possible that the middleware functions only work with RTM? And that in case of postMessage the middleware function is triggering because from it's perspective it is receiving the message? |
Hey @arnthorsnaer sorry I misread your original question. There is not currently a way to reliably know who the message is addressed to, because for slack, the only required field is the channel. This is an interesting point, and it may be that we should ensure that a user field is present there since Botkit is always talking to a specific user, even if in a public channel. On your second point, I believe you are seeing the receive middleware fire in response to message delivery confirmations and/or echos from the events API. |
I'm adding a custom middleware to send (controller.middleware.send.use) which is working as far as getting information on what text is being send and what the channel is but I am unable to figure out the user being communicated with.
Can I figure this out using the channel in the message?
The text was updated successfully, but these errors were encountered: