Predict next action

I’m using Rasa version 2.8.7 in my simple project in order to understand main product features. I wrote a custom action, some stories and a custom entity extractor.

I’d like to know if there is a way to get the next prediction action within my custom action or in every other place.

Is it possible?

Welcome to the forum! :slight_smile:

From Custom Actions, you can only see past predictions (all is stored within the tracker dictionary).

Look at POST model/predict, maybe it can help.

Thanks for your response :slight_smile:

I’ve already seen that post, however it’s not clear how it works… Is there some documentation about that API?

Well the above link is the documentation :sweat_smile: By POST I mean POST request for the REST API, not a forum post.

POST http://localhost:5005/model/predict

body: [
  {
    "event": "slot",
    "timestamp": 1559744410
  }
]

response: {
  "scores": [
    {
      "action": "utter_greet",
      "score": 1
    }
  ],
  "policy": "policy_2_TEDPolicy",
  "tracker": {
    "conversation_id": "default",
    "slots": [
      {
        "slot_name": "slot_value"
      }
    ],
    "latest_message": {
      "entities": [
        {
          "start": 0,
          "end": 0,
          "value": "string",
          "entity": "string",
          "confidence": 0
        }
      ],
      "intent": {
        "confidence": 0.6323,
        "name": "greet"
      },
      "intent_ranking": [
        {
          "confidence": 0.6323,
          "name": "greet"
        }
      ],
      "text": "Hello!"
    },
    "latest_event_time": 1537645578.314389,
    "followup_action": "string",
    "paused": false,
    "events": [
      {
        "event": "slot",
        "timestamp": 1559744410
      }
    ],
    "latest_input_channel": "rest",
    "latest_action_name": "action_listen",
    "latest_action": {
      "action_name": "string",
      "action_text": "string"
    },
    "active_loop": {
      "name": "restaurant_form"
    }
  }
}

Ok, but my question is: the predictionn should be related to some conversation with a user, instead in your body there is not any reference to user (conversation id / user id), so the prediction returned from API is related to…? And finally, timestamp parameter within body what does it represent?

Anyway, I’ve tried to call that API but I get the following error:

{

"version": "2.8.7",

"status": "failure",

"message": "Failed to validate the events format. For more information about the format visit the docs. Error: 'user' was expected\n\nFailed validating 'const' in schema[0]['properties']['event']:\n    {'const': 'user'}\n\nOn instance['event']:\n    'slot'",

"reason": "BadRequest",

"details": {},

"help": "https://rasa.com/docs/rasa/pages/http-api",

"code": 400

}

EDIT Ok, I think to have solved. My body must contains one or more events I want to simulate in order to get the prediction about the next event.

1 Like

Sorry for the late reply but glad you solved it!

Sadly yes, there is no way to include the conversation ID here.

It would not make sense anyway. You cannot predict a next action if the current one has not even finished.

Really good, thank you very much!

1 Like

@bitsystem What was the solution to this issue. Could you pls guide?