Similar Intent with different entities and Optional slot

I am creating a chatbot which could get you the multiple details and one is order details. It has the attributes of order number, name and id. Any one of the attributes can be used to get the order details. I have to add a form action to get the attributes/slots to get the details. Since the user can ask in general like, User: Can you get me the order details Bot: Yes. Please provide the name/number/id to get you the details.

The problem is, If I try to create different intent, the context of the intent will be same, it will be difficult to classify. Eg

intent:searchby_number:

  • get me details of [08141801] - (order_number)

intent: searchby_name:

  • get me details of [cerner] - (order_name)

I can combine this into single intent with different entities. eg:

intent:search_order:

  • Can you get me the order details
  • get me details of [08141801] - (order_number)
  • get me details of [cerner] - (order_name)
  • order details of [mascjx00c] - (order_id)

But how can I add the form for this because any one of the slot is enough to get the details. Can we have optional slots in a form or is there any better way to achieve this?

Thanks in advance

Hi @gunalaksh!

I think it would be better to keep them under a single intent. Also I think you should rename your entities as well (if possible) and make them a single entity. Optionally, you can use entity groups. For example like this:

## intent: search_order
- Can you get me the order details
- get me details of [08141801](search_parameter)
- get me details of [cerner](search_parameter)
- order details of [mascjx00c](search_parameter)

Now you can trigger the form action if no entity is extracted otherwise do whatever you want with it.

Hope that helps :slightly_smiling_face:.

Thanks @saurabh-m523. This might work for a case where the api will accept any parameter. The problem for me is that I have to know the type of attribute / parameter whether it’s an id or name or number to pass it in the api. It’s difficult to differentiate if I have same entity.

Hmm…well in that case you could try using entity groups.

If you don’t want to use entity groups then you can write different stories for the different scenarios. For example:

## search_intent_no_entity:
* search_order:
    - search_order_form
    - form{"name": "search_order_form"}
    - form{"name": null}
    - action_search_order
    - action_restart

## search_order_order_number
* search_order{"order_number": "08141801"}
    - action_search_order
    - action_restart

## search_order_order_name
* search_order{"order_name": "cerner"}
    - action_search_order
    - action_restart

## search_order_order_id
* search_order{"order_id": "mascjx00c"}
    - action_search_order
    - action_restart
1 Like

Thanks @saurabh-m523. I think writing different stories for different scenarios is the only way to solve this.

Sure. Try it out! :+1: let me know if it works. :smiley: