AlenChuan
(AlenChuan)
October 27, 2021, 6:53am
1
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
nik202
(NiK202)
October 27, 2021, 11:12am
2
@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.
ChrisRahme
(Chris Rahmé)
October 27, 2021, 12:00pm
3
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 .
AlenChuan
(AlenChuan)
October 28, 2021, 2:58am
4
action_request_ocr reads an image and returns 4 slots.
nik202
(NiK202)
October 28, 2021, 8:12am
5
@AlenChuan thanks for the confirm, can you please share the code for action_request_ocr i.e action.py?
AlenChuan
(AlenChuan)
October 28, 2021, 8:16am
7
I don’t have FormValidationAction…Can I use it to input values into some slots?
ChrisRahme
(Chris Rahmé)
October 28, 2021, 9:53am
8
Yes, create one. Please see all the provided links for more info.
Yes:
nik202
(NiK202)
October 28, 2021, 11:57am
9
@AlenChuan How, you getting the 4 values from the images? that the code I want to see Alen.