How to use 'get_latest_entity_values' (Dialogue state tracker)

I want to fetch the entities that are parsed and set the values of the entity in the slot.

In the documentation, it is mentioned that I can use ‘get_latest_entity_values’ under Dialogue state tracker for fetching the entities that are parsed.

Please help me with the parameter that I have to pass to make the get_latest_entity_values call and how to make the call

hey @Shreeti17 you can read this thread How to extract the name of detected entity value through Actions? - #5 by dvigneshwee

@JiteshGaikwad I am updating the slot using slotset function but the slot is not updating

  def run(self, dispatcher, tracker, domain):
    key = tracker.latest_message.intent["name"]
    l_confidence = tracker.latest_message.intent["confidence"]
    logger.info(key)
    logger.info(l_confidence)
    logger.info(tracker.get_slot("number"))
    logger.info(tracker.get_slot("so"))
    [SlotSet("so", key)]
    logger.info(tracker.get_slot("so"))
    return 

Output:

2019-01-30 13:57:24 INFO     bot  - material_list
2019-01-30 13:57:24 INFO     bot  - 0.9565813541412354
2019-01-30 13:57:24 INFO     bot  - 765678
2019-01-30 13:57:24 INFO     bot  - None
2019-01-30 13:57:24 INFO     bot  - None

Hey,

You have to return the slot set function for it to work: return [SlotSet("so", key)]

@srikar_1996 thank you :slight_smile:

@srikar_1996 slot value is reflecting in the console but not reflecting in parse continue call

story:

story_material_list

  • material_list{“number” : “number”}
  • action_test
  • action_test2

console op:

Bot loaded. Type a message and press enter: 
material under so 6789769865
2019-01-30 14:28:43 INFO     bot  - material_list
2019-01-30 14:28:43 INFO     bot  - 0.9096423983573914
2019-01-30 14:28:43 INFO     bot  - 6789769865
2019-01-30 14:28:43 INFO     bot  - None
2019-01-30 14:28:43 INFO     bot  - <class 'str'>
2019-01-30 14:28:43 INFO     bot  - material_list
2019-01-30 14:28:43 INFO     bot  - 0.9096423983573914
2019-01-30 14:28:43 INFO     bot  - 6789769865
2019-01-30 14:28:43 INFO     bot  - material_list

parse op:

http://172.16.0.195:5030/conversations/8/parse

{"query":"Materials against so 9514443459"}

{
    "next_action": "action_test",
    "tracker": {
        "events": null,
        "latest_event_time": 1548838748.7716658,
        "latest_message": {
            "entities": [
                {
                    "additional_info": {
                        "type": "value",
                        "value": 9514443459
                    },
                    "confidence": 1,
                    "end": 31,
                    "entity": "number",
                    "extractor": "ner_duckling_http",
                    "start": 21,
                    "text": "9514443459",
                    "value": 9514443459
                }
            ],
            "intent": {
                "confidence": 0.9488726854324341,
                "name": "material_list"
            },
            "intent_ranking": [
                {
                    "confidence": 0.9488726854324341,
                    "name": "material_list"
                },
                {
                    "confidence": 0.061332251876592636,
                    "name": "invoice"
                },
                {
                    "confidence": 0.05992214381694794,
                    "name": "so_list"
                }
            ],
            "text": "Materials against so 9514443459"
        },
        "paused": false,
        "sender_id": "8",
        "slots": {
            "number": 9514443459,
            "so": null
        }
    }
}

Can you post a snap of the function? Not sure what is wrong.

class ActionTest(Action):
  def name(self):
    return 'action_test'

  def run(self, dispatcher, tracker, domain):
    key = tracker.latest_message.intent["name"]
    l_confidence = tracker.latest_message.intent["confidence"]
    logger.info(key)
    logger.info(l_confidence)
    logger.info(tracker.get_slot("number"))
    logger.info(tracker.get_slot("so"))
    logger.info(type(key))
    return [SlotSet("so", key)]

class ActionTest2(Action):
  def name(self):
    return 'action_test2'

  def run(self, dispatcher, tracker, domain):
    key = tracker.latest_message.intent["name"]
    l_confidence = tracker.latest_message.intent["confidence"]
    logger.info(key)
    logger.info(l_confidence)
    logger.info(tracker.get_slot("number"))
    logger.info(tracker.get_slot("so"))
    return []

What about action_test2? It should reflect in the second action. The parse output you posted is for the action_test right, and it is returning the slot value so it should be available from for the subsequent actions.

Actually, can you try accessing it in the next story and see if the value is still there?

1. http://172.16.0.195:5030/conversations/8/parse 

{"query":"Materials against so 9514443459"}

op:
{
"next_action": "action_test",
"tracker": {
    "events": null,
    "latest_event_time": 1548840717.5628903,
    "latest_message": {
        "entities": [
           .
			   .
			   . . 
        ],
        "text": "Materials against so 9514443459"
    },
    "paused": false,
    "sender_id": "8",
    "slots": {
        "number": 9514443459,
        "so": null
    }
}


   

2.  http://172.16.0.195:5030/conversations/8/continue

   {"executed_action":"action_test"}

   {
"next_action": "action_test2",
"tracker": {
    "events": null,
    "latest_event_time": 1548840795.7925394,
    "latest_message": {
        "entities": [
         . . .
        ],
        "text": "Materials against so 9514443459"
    },
    "paused": false,
    "sender_id": "8",
    "slots": {
        "number": 9514443459,
        "so": null
    }
}
}


3.  http://172.16.0.195:5030/conversations/8/continue

   {"executed_action":"action_test2"}

op:
{
"next_action": "action_listen",
"tracker": {
    "events": null,
    "latest_event_time": 1548840915.2218843,
    "latest_message": {
        "entities": [
            {
                "additional_info": {
                    "type": "value",
                    "value": 9514443459
                },
                "confidence": 1,
                "end": 31,
                "entity": "number",
                "extractor": "ner_duckling_http",
                "start": 21,
                "text": "9514443459",
                "value": 9514443459
            }
        ],
      . . . 
        "text": "Materials against so 9514443459"
    },
    "paused": false,
    "sender_id": "8",
    "slots": {
        "number": 9514443459,
        "so": null
    }
}
}

Oh, that’s strange. I’m not sure why the value isn’t being passed in the response. Anyway, can you try accessing the value in the next story and see?

I think this is weird, why aren’t the slots reflecting in the parser output if they are in the logger? @Ghostvv @akelad and others, any thoughts?

Not sure, looks like you’re using an old version of rasa core which we no longer support though (the /continue endpoint is deprecated in the current version). I’d suggest upgrading to a newer version