Multi-entity & slots

Hi there!

I’m working on a chatbot about taxes and tax agency which has lots of entities, because of the kind of questions from the users.

I’d like some help with something like this example:

[Last year](past) I [bought]{"entity": "verb", "value": "buy"} [stocks](financial instruments) and [sold]{"entity": "verb", "value": "sell"} [bonds](financial instruments). [how](question) am I going to [declare](verb) to the [tax agency](TA).

Is it possible to build a story like this one?

story: Sell bonds and stocks - declare
  steps:
  - intent: financial_instruments
    entities:
    - past: last year
	- verb: buy
    - verb: sell
	- verb: declare
    - financial instruments: stocks
	- financial instruments: bonds
    - question: how
	- TA: tax agency
  - slot_was_set:
    - verb: buy, sell, declare              <-------------------------------------------- is this possible?
  - slot_was_set:
    - financial instruments: stocks, bonds  <-------------------------------------------- is this possible?
  - action: utter_declare_financial_instruments

The problem is that I must use a lot of “verb” entities in order to give the correct answer to the user. I wonder if it is possible to store multiple “verb” in a slot, like in the story above?

Or is it better to use another way, like using “Group” in the entities?

Thanks in advanced!

Pedro Lopes

Hi Pedro!

I can see the approach you’re taking here, but I think best bet would actually probably be rethinking how you’re using entities. In this case you have several entities (buy, sell, declare & possibly how) that I might recommend reworking as intents instead. In general, you can ask: are there a lot of ways for someone to express this piece of information/thing they want to do (intent) or will they do it with a fairly consistent surface form that you can predict to remember and reference (entity)?

A little bit deeper of an explanation for your case: If you use the exact verbs “buy”, “sell” etc. your bot will be very brittle; you’ll never get the right flows if someone uses different phrasing or even tense. (e.g. “I bought 50 shares of XXX”, “I got 50 shares”, “I added 50 shares”, etc.). Intents are designed to allows more flexibility in how someone phrases things. You can still set slots using the intents in a form by using from_intent: Forms

(Given the number of pieces of information it looks like you need to collect I’d recommend a form regardless. My guess, unless you have users that use chatbots in a way I haven’t really seen, is that you’ll get inputs more like “I need to declare stocks” and you’ll need a way to get the rest of the information anyway.)

3 Likes

Hi Rachael,

Thanks for your feedback. I’m implementing a nacional Taxbot Agency.

The questions from the users are from very broad subjects, for example.

  • “How do I get a password for the online TAX Agency?”
  • “How do I change the password?”
  • “When do I have to submit my Income tax form?”
  • “How to I fill the X or Y form?”
  • “How do I pay my car taxes?”
  • “How to pay my debts in monthly installments?”

We have about 6 or 7 different taxes, which have almost the same kind of questions.

From what I understood from your answer, I should create a intent for diferent kind of questions, right? For instance:

- intent: when_submit
  examples: |
    - when do I deliver the [income form](form_type)?
    - what's the time to submit the [income form](form_type)?
    - when should I register the [house tax form](form_type)?

I should let the verbs “out” and do an intent aproach?

Is this a good approach?

Thanx in advanced!

Pedro Lopes

Yep, exactly!

If you want to tailor responses to a specific type of tax you could have a question about which tax they have questions about (I’d probably use buttons here) and use conditional response variations (more info: Now Available in Rasa Open Source: Conditional Response Variations | The Rasa Blog | Rasa) to select the right response & reduce the number of stories you need.

1 Like

Thanxs Rachael!

I’ll give it a try!