How can I know which platform user send message (telegram, slack or facebook messenger) when handle custom actions?
You should be able to achieve that by passing input_channel
attribute UserMessage class which will store the channe which the message came trough. Then, you can get the value of the input channel using the tracker: tracker.get_latest_input_channel
@Juste, can you please show a simple example on how to do this?
I have passed like below and called tracker.get_latest_input_channel
inside action.py which throws AttributeError: ‘Tracker’ object has no attribute ‘get_latest_input_channel’
input_channel = SlackInput(SLACK_BOT_TOKEN)
print(input_channel)
print(port)
agent.handle_channels([input_channel], int(port), serve_forever=True).
Though i know am getting input from Slack platform, i need to know, from which slack channel Input is being sent.
I just updated Rasa Core to version 0.11.12 and I still got the error message:
"AttributeError: 'Tracker' object has no attribute 'latest_input_channel'"
"AttributeError: 'Tracker' object has no attribute 'get_latest_input_channel'"
"AttributeError: 'Tracker' object has no attribute 'get_latest_input_channel()'"
Follow the doc at: https://rasa.com/docs/core/0.11.12/_modules/rasa_core/trackers. I think this attribute should be in the tracker now.
Has anyone run into the same problem?
I also post the question to Stack Overflow. If there are useful answers, I will re-up them here.
Finally I found the solution. Just get input_channel from Events.
input_channel = tracker.events[1]['input_channel']
Hope the input_channel will be fixed for next release of RASA.
@vinhphat89 Any idea on how to find from which Slack channel id the user sends the message?
@vigneshp826 I’m not sure about Slack but we can use sender_id to identify the conversation between bot and user. In my case is Telegram.
We can manually send the messages to user based on sender_id. (more references at Telegram Bot API and chat_id is sender_id when you call sendMessage function)
@vinhphat89 in my case, normally i will get 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’}
In Rasa, sender_id just provides “user” details. Btw i created a new topic on this Find Slack Channel ID.
Thank you very much for your insights
You should use tracker.get_current_state().get(‘latest_input_channel’) because you’re using the rasa_core_sdk where the get_latest_input_channel() method doesn’t exist, but it’s returned as part of the tracker state.
With RASA 1.9.6 we can get input channels in actions using below code:
channel = tracker.get_latest_input_channel()
print(channel)
hi. can you give an example code for this? i want to edit the message of the bot on telegram but i dont know how to access it through actions.py thank you!
pls mark this as solution