How to handle conversation-specific entities?

Hi folks,

I’m migrating to Rasa from Dialogflow and I’ve run into a few snags I’m hoping I can get some input on. I’ve pored over the documentation and a multitude of search results so hopefully I’m not asking anything too obvious here.

How can I populate some customer-specific entities into a conversation?

I have some entity values that I’d like captured by my intents, but they’re customer/conversation specific. I don’t want to include them in my general training set since I wouldn’t want them to get picked up in other conversations. Based on what I’ve read in the docs, if there’s a slot with the same name as the entity, it’ll consider those slot values for entity capture as well, which sounds like it could do the trick. But, it doesn’t appear to be working. My intention is to populate those slots via custom actions but for now I’m testing it out by forcibly adding some slot values to conversations via my domain.yml file: slots: fave-video-game: type: list initial_value: [‘Legend of Zelda’,‘Pong’] auto_fill: false

“fave-video-game” corresponds to an entity that I use to capture video game titles in intents (these two don’t exist in my training data).

But, even with this in place, if I include one of those two game titles as the video game in the intent, it won’t capture them in the fave-video-game entity. (I’m using the default pipeline config BTW, with the DIETClassifier for entity capture)

I’ve tried it with and without store_entities_as_slots and auto_fill enabled for these slots on the basis that maybe it doesn’t look there if those are disabled but that didn’t seem to make a difference.

Is there a better way to handle this?

Thanks!

If you have an entity whose type is fave-video-game and a slot named fave-video-game and would like that slot to be filled whenever a value of the fave-video-game entity is extracted, then you need to set store_entities_as_slots and auto_fill to true. The details of this are described in our docs here.

What does your training data look like? It sounds like you have insufficient examples of utterances that have the entity fave-video-game in it.

Hi Hsm207,

Thanks for the reply. I’m not looking to fill a slot with a value it extracted from an intent, I was aiming to fill the slot in advance for the purpose of giving the system some values with which it could determine what type of entity it is. For example, I have another intent that looks like this:

- intent: Start Roll Call
  examples: |
    - Game bot add player [Jen](player-first-name)
    - Game bot add player [Bruno](character-first-name)

As you can see, the format of the intent is fairly fixed but the entity being captured could change. For player first names, I could have a lookup of real names, but character names are generated by users, potentially moments before using the chatbot, so I wouldn’t have a pre-defined lookup for those. Also, Bruno can be a real person’s name too so that could wind up getting returned as a player name incorrectly as well which is an issue. My original thought was that by giving it some slots filled with player names and character names, it could use those to determine which entity to capture with more certainty.

But, after giving it some more thought, beyond the fact that it’s not using my slot values as entities the way I had expected, I think it’s a flawed approach in general. I’ve got an alternate approach in mind that I think will work better. I’m going to leave it to my custom action to determine what type of user it is. So, now my plan is to change my intent to something like:

- intent: Start Roll Call
  examples: |
    - Game bot add player [Jen](first-name)

And, like you suggested, I’ll enable store_entities_as_slots and auto_fill to true so that when I say something like “Game bot add player Bilbo”, it can grab the value Bilbo based on its placement in the sentence rather than relying on the value existing in the training data (i.e. inferred entity value). Then, when it gets passed back to me via custom action, I’ll check whether it’s a player name or a character name and handle it accordingly.

At least that’s the theory. It’s not clear to me from the docs if the store_entities_as_slots/auto_fill is what’s needed to allow it to infer values and return them as entities (so far all my tests have returned a blank entity when provided with a word that isn’t explicitly in the training data) but I’m going to give it a test.

I got it going. Turns out what I needed was to enable the CRFEntityExtractor in my pipeline and now it appears to be able to pick up entity values from the input even if they aren’t in a lookup table or in the training data. No need for the slot stuff.

Unrelated question: I also added the DucklingEntityExtractor to my pipeline since there’s an entity or two that I want to be handled by that. The docs say “If you use multiple entity extractors, we advise that each extractor targets an exclusive set of entity types” but I can’t seem to find an example of where/how to set the target entities for an extractor. Can you point me in the right direction for that info?

I tried specifying it in my domain.yml file like this but it didn’t use Duckling when I tested it out:

entities:
  - first-name
  - last-name
  - level:
      extractor: DucklingEntityExtractor

Responding to my own message here since I figured out how to target Duckling to a specific entity.

From what I can tell, the short answer is “you don’t”. My original expectation was that I could configure the system to say “Use Duckling to evaluate the entity named building-floor instead of my default extractor of CRFEntityExtractor” so that when an utterance matching my rule I live on the [fourth](building-floor) floor is encountered, it would return the value “4” instead of “fourth” for building-floor (without needing a synonym to map every ordinal word to its respective numeric value).

But, I never found a way to setup that mapping of extractor-to-entity. Here’s how I got the result I wanted instead:

  1. Install the Duckling http extractor
  2. Add it to the project pipeline in config.yml (and in my case I restricted it to the “number” and “ordinal” dimensions - see example pipeline config below)
  3. Add “number” and “ordinal” in your list of entities in domain.yml.
  4. Now, Duckling will automatically parse numbers and ordinals out of every utterance and include “number” and “ordinal” entries in the list of extracted entities for each utterance (and pass those along to my custom action).
  5. In my custom action, when I parse out the “building-floor” entity - knowing that I’m expecting a numeric value - I check if there’s an associated “number” or “ordinal” entity with the same “start” and “end” value. If so, I grab the value from the number/ordinal entity’s [‘additional_info’][‘value’] field instead of using the value in the building-floor entity record itself. NOTE: It’s important to grab the value from the Duckling entity’s additional_info key and not the one at the root of the entity result since it’s sometimes wrong.

Pipeline config:

- name: DucklingEntityExtractor
  url: "http://localhost:8000"
  dimensions: ["number","ordinal"]

I hope that info is useful to others as well!

Marking my answer as a solution in order to close this thread but it should be noted that this may not be the “official” solution. Just the one that worked for me.