How to add action into a form

I write action_request_ocr to get “price” and “departure_station” from the “ticket” that the user provides. How to add this action into the form?

trip_form:
    ignored_intents:
    - chitchat
    required_slots:
      ticket:
      - entity: ticket
        type: from_entity
      - type: from_text
      price:
      - type: from_entity
        entity: price
      - type: from_text
      departure_station:
      - type: from_entity
        entity: departure_station
      - type: from_text
actions:
- action_request_ocr

@AlenChuan do this action_request_ocr reading the data from Image or reading the data with some API? can you confirm it? or please share some example of bot/user conversation please.

You can use Custom Actions inside Forms. They’re called FormValidationAction.

Instead of run(), you have:

  • extract_slotname(): Write logic to extract the slot from the user’s message and return a dictionary of slot names and their values.
  • validate_slotname(): Write logic to check if the slot slotname is valid and return a dictionary of slot names and their values.
  • required_slots(): Write logic to decide which slots should be asked about and return a list of slot names.

Please see: Forms: Advanced Usage.

action_request_ocr reads an image and returns 4 slots.

@AlenChuan thanks for the confirm, can you please share the code for action_request_ocr i.e action.py?

I don’t have FormValidationAction…Can I use it to input values into some slots?

Yes, create one. Please see all the provided links for more info.


Yes:

@AlenChuan How, you getting the 4 values from the images? that the code I want to see Alen.