What's the best way to overwrite entity values for a certain condition?

My weather robot is like this:

* Is going to be rain tomorrow?
   yes.
* Is going to be snow tomorrow?
  no

If I define [rain, snow, fog, mist] as a list, and they are defined as different entity types in the robot. For a new utterance (‘is going to be snow tomorrow’), if ‘snow’ is extracted as an entity, and if any of the [rain, snow, fog, and mist] entities already exist in the tracker, this previous entity should be discarded (i.e. rain), and will be replaced with the new entity ‘snow’. That is, the previous entity should be forgotten, instead of keeping it in the history.

If I implement this logic as an action, where to call this action? It doesn’t seem to be a way to do that. Currently I implement the logic in the MessageProcessor class. It seems messy. e

Is there a general strategy to do this in the action class? That will limit the code specific to a skill within its own action class, instead of the generic MessageProcessor class.

Thanks.

I think for this you want slots, do you mean slots? These shoud all be one entity, e.g.

slots:
  precipitation:
     type: categorical
     values:
       - fog
       - mist 
       - snow
       - rain

entities: 
  - precipitation

You can use synonyms to map similar words to the categories, i.e.

- Is it going to [rain](precipitation) tomorrow?
- Will it be [rainy](precipitation:rain) tomorrow?

and at the bottom

## synonym:rain
- rainy
- pour
- downpour

etc. for each of yoru types of precipitation.

Then when it parses a message, if it finds an instance of precipitation, it should autofill that slot (overwriting whatever was in it), and you can use the slot to change your dialog flow.

1 Like

Thanks Erohmensing, that seems a much elegant approach.

Of course! Let me know how it goes :slightly_smiling_face: