python - How to add a Slack reaction to a send_card


Keywords:python 


Question: 

I have an Errbot function that sends a Slack card. How do I then add a reaction to the card instead of the original message(msg) that was received?

@botcmd
def example(self, msg):
    self.send_card(title='Test',
            body='test123',
            thumbnail=' ',
            image=' ',
            link=' ',
            color='green',
            in_reply_to=msg)
    self._bot.add_reaction(card_msg??, 'grey_question')

1 Answer: 

send_card does not return to you the message it sends which means you will have to do something to get the message info of the card you sent.

One option would be to trigger a callback for all messages in your plugin, inspect the message, and add your reaction there:

Another option could be to use the slack backend api call method to search for your message and add the reaction that way.