Duckling entity exrtractor overwrites numerical slots in a form

Following the codebase of the financial demo found here https://github.com/RasaHQ/financial-demo

I have edited the transfer_money_form with an additional OTP number (numerical), however, duckling captures the OTP and overwrites the amount-of-money slot as well.

Example: Person: Transfer 5000 to John (Bot sets slots amount-of-money: 5000 and PERSON: John) Bot: Please enter OTP Person: 1234 (Bot sets both amount-of-money and OTP slots to 1234) Bot: OTP correct. Transfered $1234 to John

This happens because both slots are filled with ‘number’ duckling entity.

How can we avoid this behaviour?

Hi @ma7555

You can control this behavior in the form definition by specifying conditions from which intent the slot should fill.

Hello @siriusraja

All intents are actually inform as the user can be asked about the amount and OTP in seperate questions in which he will reply:

5000

1234

Hi @ma7555

You should be able to achieve this by using Custom slot mappings https://rasa.com/docs/rasa/2.0.x/forms#custom-slot-mappings

Please have a look at the above docs. Also share your form definition, slot names, custom action to understand your current set-up.

Hello @siriusraja, my current setup is identical to rasa financial demo, with an extra slot ‘otp’ filled from_text only.

Problem is otp, since it is a number, overwrites amount-of-money

are you using the duckling amount-of-money extractor? Usually the amount-of-money won’t extract simply numbers out of text unless a currency is mentioned in the pattern.

in the form, you can even specify which intents to exclude with respect to slot mappings take a look at this exmaple - Forms

the not_intent is something you can specify for the amount-of -money slot so that it avoids the capturing OTP intent.

@souvikg10 I am using both number and amount-of-money extractor as the currency is unified - Same setup as the financial-bot demo.

please note that OTP is not an intent but a slot, usually filled by ‘inform’ intent

I understand that. Usually if you are using the form for collecting the information, let’s take one example from one of the forms in the demo

  cc_payment_form:
    AA_CONTINUE_FORM:
    - intent: affirm
      type: from_intent
      value: yes
    - intent: deny
      type: from_intent
      value: no
    - intent:
      - inform
      - cc_payment_form
      type: from_text
    credit_card:
    - entity: credit_card
      type: from_entity
    - intent:
      - inform
      - cc_payment_form
      type: from_text
    amount-of-money:
    - entity: amount-of-money
      not_intent:
      - check_balance
      - check_earnings
      - INFORM_OTP
      type: from_entity
    OTP:
    - entity: OTP
      not_intent:
      - check_balance
      - check_earnings
    type: from_entity
    - entity: number
      not_intent:
      - check_balance
      - check_earnings
      type: from_entity
    - intent:
      - inform
      - cc_payment_form
      type: from_text
    time:
    - entity: time
      type: from_entity
    - intent:
      - inform
      - cc_payment_form
      type: from_text
    zz_confirm_form:
    - intent: affirm
      type: from_intent
      value: yes
    - intent: deny
      type: from_intent
      value: no
    - intent:
      - inform
      - cc_payment_form
      type: from_text

Check the amount-of-money slot, in the note_intent part, add the intent that collects the OTP

both amount-of-money and otp uses the same intent ‘inform’, don’t think spliting both informs will work as both willl have digits as examples

Any available solutions? we want to avoid overwritting the amount-of-money (can be filled with number entity) when user inputs the otp (filled by number entity)

As far i remember the duckling parser for amount-of-money, i find it surprising that an ordinary number without any currency mentioned is being picked up by amount-of-money.

have you provided tagged examples for amount-of-money in the training data?

duckling works in haskell with a very strong regex pattern to extract currency patterns and it does not require training examples. if you have given training examples for the same, you are not “training” a duckling extractor but DIET which maybe is filling the slot instead. try removing all tagged examples of duckling amount-of-money from the training examples.

p.s i wrote the amount of money extractor in duckling for dutch 2 years ago so as far as i know, amount-of-money can’t just pick numbers in random, it does not have a regex for that

Hello souvikg10, please note that the amount-of-money slot in the financial demo example, can be filled with duckling amount-of-money enitity or number enitity. please check the domain file I have provided.

This behaviour is needed so you do not need to provide a currency.

i understand. then perhaps the creators of the demo could help @akelad. I can’t think of any other way to implement this. sorry :frowning:

personally coming from a financial industry, i would never imagine a number being considered amount of money because it adds a huge level of randomness to a field which is considered very highly in banking - “Money”. i think amount-of-money should only look for patterns where the user indicates currency and thus in duckling rules, this has been strictly maintained. in our case, we guided the user to input the currency or currency symbols if you don’t control the UI and added further validation steps. numbers are very random and can occur in multiple scenarios and thus i would refrain from using numbers as part of the enttiy extraction for amount of money.

@ma7555 can you share your form definition from the domain file here please? I’d like to see how you’ve defined this new slot to be filled

Hello @akelad , please find it here

amount-of-money:

    - entity: amount-of-money

      not_intent:

      - check_balance

      - check_earnings

      type: from_entity

    - entity: number

      not_intent:

      - check_balance

      - check_earnings

      type: from_entity

    - intent:

      - inform

      - transfer_money_form

      type: from_text