Slot values being overwritten in Rasa

Hi Afnaan, I had a similar problem with two integer slots that are similar and were overwriting each other: account number and transfer amount. What I did was create one entity called “number” with two roles, one for “account number” and one for “transfer amount”. In my nlu.yml, I put all examples of these entities in a single “inform” intent. I allowed the nlu to identify the number entity without any role attached to it when only a number was given, as well as more detailed examples with entity and role identified:

nlu:
- intent: inform
  examples: |
    - [1]{"entity": "number"}
    - [2]{"entity": "number"}
    - [3]{"entity": "number"}
    - [4]{"entity": "number"}
    - [5]{"entity": "number"}
    - [100]{"entity": "number"}
    - [2567]{"entity": "number"}
    - [721321567]{"entity": "number"}
    - [534412]{"entity": "number"}
    - I want to send [333]{"entity": "number", "role": "transfer_amount"}
    - Send to [2]{"entity": "number", "role": "transfer_recipient"}

I then set up my slots to extract from the number entity when the role was identified (i.e. when the user said “account 3” for example) and to extract from the number entity when no role was identified (i.e. when the user just said “3”) under the condition that my form was active and the requested slot was the respective slot. See below.

slots:
  transfer_recipient:
    type: text
    influence_conversation: true
    mappings:
    - type: from_entity
      entity: number
      role: transfer_recipient
    - type: from_entity
      entity: number
      conditions:
      - active_loop: send_transfer_form
        requested_slot: transfer_recipient
  transfer_amount:
    type: text
    influence_conversation: true
    mappings:
    - type: from_entity
      entity: number
      role: transfer_amount
    - type: from_entity
      entity: number
      conditions:
      - active_loop: send_transfer_form
        requested_slot: transfer_amount

Caveat that I’m new to rasa, but this has been working for me so far.

2 Likes

Hi, I had the same problem. It turned out that while validating the slots in actions.py, I was returning the other slot to be set. eg: in my case i had place and budget as slots, in budget i was returning this: return {“place”: slot_value}. So make sure you keep this in mid. Hope this helps