Closed thepavangollapalli-zz closed 7 years ago
@thepavangollapalli did you figure this out? I need to mutate my outbound messages and user info is absolutely critical part of this process.
What user information specifically are you unable to find? Can you share some code?
User id is not explicitly needed to deliver a message, but is usualy hanging out on the message depending on how that message is sent.
You are looking to augment the Send middleware, and want access to the slack userid in that middleware, correct? On Thu, Aug 10, 2017 at 8:02 AM slearner notifications@github.com wrote:
@thepavangollapalli https://github.com/thepavangollapalli did you figure this out? I need to mutate my outbound messages and user info is absolutely critical part of this process.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/howdyai/botkit/issues/921#issuecomment-321531873, or mute the thread https://github.com/notifications/unsubscribe-auth/AMUR2wwBGNEOFZhzVqnsNucUNPJVeAvYks5sWvFYgaJpZM4OReee .
Go to node_modules/botkit/lib/Slackbot_worker.js
and find the function bot.replyPublic
. The functions following replyPublic all have a src object passed in that contains userid and several other things you can attach to the outgoing message object, simply by adding something like msg.user = src.user
after the line msg.channel = src.channel
that is in each function.
Update: I was able to get the information I needed by using the Heard middleware instead without modifying the slackbot-worker file!
I'm working with the Send and Receive middleware on a Slack chatbot and trying to store the user id of an outgoing message, but wasn't able to find any good ways to do it. I've found methods that use the api like
or
but msg.user only exists for incoming messages in the Receive middleware and so those solutions do not work for the Send middleware. I was able to get the user id by editing the slack worker so it manually returns the destination user id, but any non-hacky solutions would be great!