Find Slack Channel ID

Hi @ricwo

I can find the user who sent the message from Slack platform using ‘tracker.sender_id’ in actions.py. Is there any way we could find the Slack Channel ID from which the message has been sent?

For example, if an input comes from https://example.slack.com/messages/DAT7U3PST, i want to catch and use DAT7U3PST inside actions.py

Normally am getting the payload like below when i use slack events adapter instead of RASA.

message output: {‘type’: ‘message’, ‘ts’: ‘1545818978.001400’, ‘client_msg_id’: ‘43fb4827-fddd-4dc1-985a-eef3b3b4b1ad’, ‘text’: ‘hi’, ‘channel_type’: ‘im’, ‘channel’: ‘DAT7U3PST’, ‘user’: ‘W94SC8XU7’, ‘event_ts’: ‘1545818978.001400’, ‘team’: ‘T02N7570P’}

Hi @vigneshp826, the channel attribute isn’t currently accessible in Rasa Core

@ricwo thanks for the reply.

Any other suggestion to capture recipient_id inside actions.py so that i can use my own slack_client api call to post message instead of using dispatcher?

I’m not sure how to best do this. One way would be to try modifying sender_id in process_message to be a combination of the channel and the sender:

(...)

elif self._is_user_message(output):
                    modified_sender_id = output.get('event').get('user') + '_' + output.get('event').get('channel')
                    return self.process_message(
                        on_new_message,
                        text=output['event']['text'],
                        sender_id=modified_sender_id)

Then in send_text_message you would post the message back to

recipient = recipient_id.split('_')[0]

And then in your actions.py, the channel would just be

channel = tracker.sender_id.split('_')[-1]

Has there already been found a way to get the channel id the user responds in?