Knowing Bot's immediate reply from tracker

Is there any way i can get bot utterrence from tracker just like “tracker.latest_message” gives the detail of user input .

feedbacks are appreciated :slight_smile:

i think i already answered this, the closest thing is tracker.latest_action

May be i missed it , thanx :slight_smile:

Could you direct me to the py file(s) where i can get an in depth knowledge about the attributes/properties of tracker. I tried going through tracker.py but i didn’t find any key/attribute named “latest_action” .

Thanx in advance

my bad, it’s latest_action_name, but yeah the source code here has all the attributes: rasa_core/trackers.py at master · RasaHQ/rasa_core · GitHub

tracker.latest_action_name throws an error , says "tracker object has no latest_action_name attribute "

You need to get the tracker state first:

state = tracker.current_state()
latest_action = state.get("latest_action_name")
2 Likes

Are you sure this technique works ? coz i tried and it throws an error

DEBUG:rasa_core_sdk.executor:Received request to run ‘action_check_intent’ ERROR:flask.app:Exception on /webhook [POST] Traceback (most recent call last): File “C:\Users\sanmazum\AppData\Local\Continuum\anaconda3\envs\rasa_11_3\lib\site-packages\flask\app.py”, line 2292, in wsgi_app response = self.full_dispatch_request() File “C:\Users\sanmazum\AppData\Local\Continuum\anaconda3\envs\rasa_11_3\lib\site-packages\flask\app.py”, line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File “C:\Users\sanmazum\AppData\Local\Continuum\anaconda3\envs\rasa_11_3\lib\site-packages\flask_cors\extension.py”, line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File “C:\Users\sanmazum\AppData\Local\Continuum\anaconda3\envs\rasa_11_3\lib\site-packages\flask\app.py”, line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File “C:\Users\sanmazum\AppData\Local\Continuum\anaconda3\envs\rasa_11_3\lib\site-packages\flask_compat.py”, line 35, in reraise raise value File “C:\Users\sanmazum\AppData\Local\Continuum\anaconda3\envs\rasa_11_3\lib\site-packages\flask\app.py”, line 1813, in full_dispatch_request rv = self.dispatch_request() File “C:\Users\sanmazum\AppData\Local\Continuum\anaconda3\envs\rasa_11_3\lib\site-packages\flask\app.py”, line 1799, in dispatch_request return self.view_functionsrule.endpoint File “C:\Users\sanmazum\AppData\Local\Continuum\anaconda3\envs\rasa_11_3\lib\site-packages\flask_cors\decorator.py”, line 128, in wrapped_function resp = make_response(f(*args, **kwargs)) File “C:\Users\sanmazum\AppData\Local\Continuum\anaconda3\envs\rasa_11_3\lib\site-packages\rasa_core_sdk\endpoint.py”, line 72, in webhook response = executor.run(action_call) File “C:\Users\sanmazum\AppData\Local\Continuum\anaconda3\envs\rasa_11_3\lib\site-packages\rasa_core_sdk\executor.py”, line 177, in run events = action(dispatcher, tracker, domain) File “Z:\Desktop\bitbucket\rasa7\chatbot-rest-service\rasa\q7\actions.py”, line 173, in run pprint(tracker.current_state().get(‘latest_action_name’)) File “C:\Users\sanmazum\AppData\Local\Continuum\anaconda3\envs\rasa_11_3\lib\site-packages\rasa_core_sdk_init_.py”, line 61, in current_state latest_event_time = self.events[-1].timestamp AttributeError: ‘dict’ object has no attribute ‘timestamp’ 127.0.0.1 - - [2018-12-12 12:33:11] “POST /webhook HTTP/1.1” 500 412 0.048516

@Abir I’m using this exact snippet to get the latest message from the tracker:

current_state = tracker.current_state()
msg = current_state.get('latest_message', {}) 

I’m running the latest 0.12.4a.

It looks to me like something’s wrong with your events. Every event should have a timestamp, but your latest event seems to have none.

You’re right. Worked for me. Thanks

Beating around the bush. Apply some common sense dude!

i am using 0.11.3 release , i am kind of restricted to it due to some business needs. is it because of the versions ? Here’s an interesting thing , tracker instance itself contains “events” keys which in turn contains several events with their respective timestamps . when i access all those events from “events” key , they seem to have timestamps for all events.Here’s the content

[{‘event’: ‘action’, ‘name’: ‘action_listen’, ‘timestamp’: 1545032583.0517068}, {‘event’: ‘user’, ‘parse_data’: {‘entities’: [], ‘intent’: {‘confidence’: 0.9739776849746704, ‘name’: ‘sequence’}, ‘intent_ranking’: [{‘confidence’: 0.9739776849746704, ‘name’: ‘sequence’}, {‘confidence’: 0.009923260658979416, ‘name’: ‘affirm’}, {‘confidence’: 0.0, ‘name’: ‘inform’}, {‘confidence’: 0.0, ‘name’: ‘out_of_bound’}, {‘confidence’: 0.0, ‘name’: ‘deny’}], ‘text’: "what’s the last sequence number visa recieved for " ‘this company’}, ‘text’: “what’s the last sequence number visa recieved for this company”, ‘timestamp’: 1545032583.5292966}, {‘event’: ‘action’, ‘name’: ‘action_check_intent’, ‘timestamp’: 1545032585.482873}, {‘event’: ‘slot’, ‘name’: ‘conv_id’, ‘timestamp’: 1545032585.482873, ‘value’: ‘1’}, {‘data’: {‘attachment’: None, ‘buttons’: None, ‘elements’: None}, ‘event’: ‘bot’, ‘text’: ‘Sure, I just need a few details. First, what is your region ID?’, ‘timestamp’: 1545032585.482873}, {‘event’: ‘action’, ‘name’: ‘action_listen’, ‘timestamp’: 1545032585.50219}, {‘event’: ‘user’, ‘parse_data’: {‘entities’: [], ‘intent’: {‘confidence’: 0.0, ‘name’: None}, ‘text’: ‘’}, ‘text’: ‘’, ‘timestamp’: 1545032587.7514813}, {‘event’: ‘action’, ‘name’: ‘action_fallback_handle’, ‘timestamp’: 1545032588.7917173}, {‘event’: ‘rewind’, ‘timestamp’: 1545032588.7917173}, {‘data’: {‘attachment’: None, ‘buttons’: None, ‘elements’: None}, ‘event’: ‘bot’, ‘text’: ‘Please provide valid data !!’, ‘timestamp’: 1545032588.7917173}, {‘event’: ‘action’, ‘name’: ‘action_listen’, ‘timestamp’: 1545032588.8027184}, {‘event’: ‘user’, ‘parse_data’: {‘entities’: [{‘confidence’: 0.987197244440415, ‘end’: 1, ‘entity’: ‘param’, ‘extractor’: ‘ner_crf’, ‘start’: 0, ‘value’: ‘1’}], ‘intent’: {‘confidence’: 0.956165075302124, ‘name’: ‘inform’}, ‘intent_ranking’: [{‘confidence’: 0.956165075302124, ‘name’: ‘inform’}, {‘confidence’: 0.056787148118019104, ‘name’: ‘affirm’}, {‘confidence’: 0.0, ‘name’: ‘sequence’}, {‘confidence’: 0.0, ‘name’: ‘out_of_bound’}, {‘confidence’: 0.0, ‘name’: ‘deny’}], ‘text’: ‘1’}, ‘text’: ‘1’, ‘timestamp’: 1545032593.6809158}, {‘event’: ‘action’, ‘name’: ‘action_check_reg’, ‘timestamp’: 1545032594.7121992}, {‘event’: ‘slot’, ‘name’: ‘regid’, ‘timestamp’: 1545032594.7121992, ‘value’: ‘1’}, {‘data’: {‘attachment’: None, ‘buttons’: None, ‘elements’: None}, ‘event’: ‘bot’, ‘text’: ‘And the processor ID?’, ‘timestamp’: 1545032594.7121992}, {‘event’: ‘action’, ‘name’: ‘action_listen’, ‘timestamp’: 1545032594.7211976}, {‘event’: ‘user’, ‘parse_data’: {‘entities’: [{‘confidence’: 0.987197244440415, ‘end’: 1, ‘entity’: ‘param’, ‘extractor’: ‘ner_crf’, ‘start’: 0, ‘value’: ‘1’}], ‘intent’: {‘confidence’: 0.956165075302124, ‘name’: ‘inform’}, ‘intent_ranking’: [{‘confidence’: 0.956165075302124, ‘name’: ‘inform’}, {‘confidence’: 0.056787148118019104, ‘name’: ‘affirm’}, {‘confidence’: 0.0, ‘name’: ‘sequence’}, {‘confidence’: 0.0, ‘name’: ‘out_of_bound’}, {‘confidence’: 0.0, ‘name’: ‘deny’}], ‘text’: ‘1’}, ‘text’: ‘1’, ‘timestamp’: 1545032596.665796}, {‘event’: ‘action’, ‘name’: ‘action_check_proc’, ‘timestamp’: 1545032597.6950412}, {‘event’: ‘slot’, ‘name’: ‘procid’, ‘timestamp’: 1545032597.6950412, ‘value’: ‘1’}, {‘data’: {‘attachment’: None, ‘buttons’: None, ‘elements’: None}, ‘event’: ‘bot’, ‘text’: ‘And the issuer/bank ID?’, ‘timestamp’: 1545032597.6950412}, {‘event’: ‘action’, ‘name’: ‘action_listen’, ‘timestamp’: 1545032597.7000358}, {‘event’: ‘user’, ‘parse_data’: {‘entities’: [{‘confidence’: 0.987197244440415, ‘end’: 4, ‘entity’: ‘param’, ‘extractor’: ‘ner_crf’, ‘start’: 0, ‘value’: ‘1940’}], ‘intent’: {‘confidence’: 0.956165075302124, ‘name’: ‘inform’}, ‘intent_ranking’: [{‘confidence’: 0.956165075302124, ‘name’: ‘inform’}, {‘confidence’: 0.056787148118019104, ‘name’: ‘affirm’}, {‘confidence’: 0.0, ‘name’: ‘sequence’}, {‘confidence’: 0.0, ‘name’: ‘out_of_bound’}, {‘confidence’: 0.0, ‘name’: ‘deny’}], ‘text’: ‘1940’}, ‘text’: ‘1940’, ‘timestamp’: 1545032601.5500445}, {‘event’: ‘action’, ‘name’: ‘action_check_iss’, ‘timestamp’: 1545032602.5893183}, {‘event’: ‘slot’, ‘name’: ‘issid’, ‘timestamp’: 1545032602.5893183, ‘value’: ‘1940’}, {‘data’: {‘attachment’: None, ‘buttons’: None, ‘elements’: None}, ‘event’: ‘bot’, ‘text’: ‘Enter Company-ID’, ‘timestamp’: 1545032602.5893183}, {‘event’: ‘action’, ‘name’: ‘action_listen’, ‘timestamp’: 1545032602.6033158}, {‘event’: ‘user’, ‘parse_data’: {‘entities’: [{‘confidence’: 0.987197244440415, ‘end’: 4, ‘entity’: ‘param’, ‘extractor’: ‘ner_crf’, ‘start’: 0, ‘value’: ‘1001’}], ‘intent’: {‘confidence’: 0.956165075302124, ‘name’: ‘inform’}, ‘intent_ranking’: [{‘confidence’: 0.956165075302124, ‘name’: ‘inform’}, {‘confidence’: 0.056787148118019104, ‘name’: ‘affirm’}, {‘confidence’: 0.0, ‘name’: ‘sequence’}, {‘confidence’: 0.0, ‘name’: ‘out_of_bound’}, {‘confidence’: 0.0, ‘name’: ‘deny’}], ‘text’: ‘1001’}, ‘text’: ‘1001’, ‘timestamp’: 1545032607.077465}, {‘event’: ‘action’, ‘name’: ‘action_check_com’, ‘timestamp’: 1545032608.1073542}, {‘event’: ‘slot’, ‘name’: ‘comid’, ‘timestamp’: 1545032608.1073542, ‘value’: ‘1001’}, {‘event’: ‘action’, ‘name’: ‘action_validate’, ‘timestamp’: 1545032610.922077}, {‘event’: ‘slot’, ‘name’: ‘is_valid’, ‘timestamp’: 1545032610.922077, ‘value’: True}, {‘event’: ‘action’, ‘name’: ‘action_seq’, ‘timestamp’: 1545032612.2945673}, {‘data’: {‘attachment’: None, ‘buttons’: None, ‘elements’: None}, ‘event’: ‘bot’, ‘text’: 'Unable to get response from server.Please contact BSAM team at ’ ‘bsam@visa.com for further assistance.\n’, ‘timestamp’: 1545032612.2945673}, {‘event’: ‘action’, ‘name’: ‘utter_ack2’, ‘timestamp’: 1545032612.311589}, {‘data’: {‘attachment’: None, ‘buttons’: None, ‘elements’: None}, ‘event’: ‘bot’, ‘text’: ‘Was this helpful?’, ‘timestamp’: 1545032612.311589}, {‘event’: ‘action’, ‘name’: ‘action_listen’, ‘timestamp’: 1545032612.3215895}, {‘event’: ‘user’, ‘parse_data’: {‘entities’: [], ‘intent’: {‘confidence’: 0.9498211145401001, ‘name’: ‘affirm’}, ‘intent_ranking’: [{‘confidence’: 0.9498211145401001, ‘name’: ‘affirm’}, {‘confidence’: 0.0, ‘name’: ‘inform’}, {‘confidence’: 0.0, ‘name’: ‘deny’}, {‘confidence’: 0.0, ‘name’: ‘out_of_bound’}, {‘confidence’: 0.0, ‘name’: ‘sequence’}], ‘text’: ‘yes’}, ‘text’: ‘yes’, ‘timestamp’: 1545032657.9453688}, {‘event’: ‘action’, ‘name’: ‘utter_ack1’, ‘timestamp’: 1545032657.9553716}, {‘data’: {‘attachment’: None, ‘buttons’: None, ‘elements’: None}, ‘event’: ‘bot’, ‘text’: ‘Thanks for the feedback. Do you want to make another enquiry?’, ‘timestamp’: 1545032657.9553716}, {‘event’: ‘action’, ‘name’: ‘action_listen’, ‘timestamp’: 1545032657.9639158}, {‘event’: ‘user’, ‘parse_data’: {‘entities’: [], ‘intent’: {‘confidence’: 0.891133189201355, ‘name’: ‘deny’}, ‘intent_ranking’: [{‘confidence’: 0.891133189201355, ‘name’: ‘deny’}, {‘confidence’: 0.2526514530181885, ‘name’: ‘affirm’}, {‘confidence’: 0.0017955135554075241, ‘name’: ‘inform’}, {‘confidence’: 0.0, ‘name’: ‘sequence’}, {‘confidence’: 0.0, ‘name’: ‘out_of_bound’}], ‘text’: ‘no’}, ‘text’: ‘no’, ‘timestamp’: 1545032660.8567357}]

As you see every event has a timestamp , the problem arises when i use currentState() to get dictionary data. I guess it has some issue you version :confused:

1 Like

why don’t you mind your own business

It’s the problem with 11.3 :confused:

hmm tracker.latest_action_name usually works for us – if you’re doing it from a custom action anyways

there’s a bug in 0.11.3 , even tracker.current_state() doesn’t work properly :confused:

are you sure this isn’t a bug with the code you’ve written? I just checked the code and both those functions we exist. At what point are you calling these fucntions? It may be that no tracker exists yet?

I checked many times and it does the same thing . This issue is faced by many who are or have used rasa 0.11.3

Hey, are you using Tracker bot ? I mean the app is not free and also Unwanted altcoins added that have less market life… Would you recommend using it ?