Submitting the form when only one slot is filled

I’m making a script for navigation service. The training phrases can contain names and categories:

USER: Find a KFC (placeName)

BOT: Look here.

USER: Find a cafe (placeCategory)

BOT: Here are some places in this category.

I made a response which depends on which slot is filled (“placeName” or “placeCategory”). But I don’t understand how to correctly set a form that would work when at least one of the slots is filled.

Hi @bogatov, what is the structure of your form and what info do you want to get from the user with the form?

Here is what I have now:

nlu.yml:

# LOOKUPS =====
- lookup: placeName
  examples: |
    - KFC
    - Ibis
    - ATC

- lookup: placeCategory
  examples: |
    - Food
    - Rest
    - Bank

# INTENTS =====
- intent: searchStart  #Just a few examples. In fact there are many more
- examples: | 
    - Find a [Food]{"entity":"placeCategory"}
    - Find a [KFC]{"entity":"placeName"}

rules.yml:

- rule: find a plce (activate)
  steps:
  - intent: searchStart
  - action: destination_form
  - active_loop: destination_form

- rule: find a place (submit)
  condition:
  - active_loop: destination_form
  steps:
    - action: destination_form
    - active_loop: null
    - slot_was_set:
      - requested_slot: null
    - action: utter_search

domain.yml:


# SLOTS =====
slots:
placeName:
  type: text
  influence_conversation: True
  mappings:
  - type: from_entity
    entity: placeName

placeCategory:
  type: text
  influence_conversation: True
  mappings:
  - type: from_entity
    entity: placeCategory


# ENTITIES =====
entities:
- placeName
- placeCategory

# FORMS =====
forms:
  destination_form:
    required_slots:
      - placeName
      - placeCategory

# RESPONSES =====
responses:
utter_search:
  - condition:   #The condition must work for any correct and not null value in the slot
      - type: slot
        name: placeName  
        value: true
    text: "Show a list of places with a name {placeName}"

  - condition:
      - type: slot
        name: placeCategory
        value: true
    text: "Show a list of places with a category {placeCategory}"

I want to get placeName or placeCategory. The option with different responses is not suitable, because there are more slots and their combinations on a real project.

If I understand it correctly, you have a form to either fill placeName or placeCategory?

Exactly. The problem is that training phrases can contain any of these entities or even both of them.

Please take a look into Categorical Slot

Take a look at forms and the dynamic behavior section. You can dynamically manage this with the required_slots method.

It looks like a working solution, but I still don’t understand how to write an action for my case.