Take booking a movie ticket as an example.
Let's start by listing the names of all intents. The intent of rasa is granular, and any user input can be considered an intent.So we need to enumerate the intentions of all possible user inputs in a scenario.If the intent I want to book a movie ticket is to book a movie ticket, the intent I want to see Iron Man is to report the title of the movie, and the intent I want two tickets is to report the number of votes
User input * intent intent
I want to book a movie ticket
I want to see Iron Man report the movie name
I want two tickets to report the number of votes
I want to report the time tomorrow at 2 p.m.
The corresponding actual data is:
## intent:inform_movie_name - [Xman1](movie_name) - I want to see [Xman1](movie_name) - [Xman2](movie_name) - I want to see movie [Xman2](movie_name) - [Xman3](movie_name) please - book movie [Xman3](movie_name) - [Xman4](movie_name) plz - I want to see [Xman4](movie_name) ## intent:book_movie_name - I want to see [Xman1](movie_name) - I want to book [Xman1](movie_name) - help me book [Xman1](movie_name) - help me book [Xman2](movie_name) - help me book [Xman3](movie_name) - help me book [Xman4](movie_name) - [Iron Man](movie_name) - book movie [Iron Man](movie_name) - [The Incredible Hulk](movie_name) - book movie [The Incredible Hulk](movie_name) - [Iron Man 2](movie_name) - book movie [Iron Man 2](movie_name) - [Thor](movie_name) - book movie [Thor](movie_name) - [Captain America](movie_name) - book movie [Captain America](movie_name) - [The Avengers](movie_name) - book movie [The Avengers](movie_name) - [Iron Man 3](movie_name) - book movie [Iron Man 3](movie_name) - [Thor:The Dark World](movie_name) - book movie [Thor:The Dark World](movie_name) ## intent:inform_weekday - I want [monday](weekday) - [monday](weekday) - It is [monday](weekday) - [wednesday](weekday) - It is [wednesday](weekday) - [thursday](weekday) - It is [thursday](weekday) - [friday](weekday) - It is [friday](weekday) - [today](weekday) - It is [today](weekday) - [tomorrow](weekday) - It is [tomorrow](weekday) - [tonight](weekday) - It is [tonight](weekday) - [this morning](weekday) - It is [this morning](weekday) - [this noon](weekday) - It is [this noon](weekday) ## intent:inform_ticket_number - book [two](ticket_number) tickets - for [two](ticket_number) people - [one](ticket_number) people - [one](ticket_number) - I want [one](ticket_number) tickets - [two](ticket_number) - I want [two](ticket_number) tickets - [three](ticket_number) - I want [three](ticket_number) tickets - [1](ticket_number) - I want [1](ticket_number) tickets - [2](ticket_number) - I want [2](ticket_number) tickets - [3](ticket_number) - I want [3](ticket_number) tickets - [single](ticket_number) - I want [single](ticket_number) tickets ## intent:inform_time - [9 am](time) - book movie at [9 am](time) - [afternoon](time) - book movie at [afternoon](time) - [3pm](time) - book movie at [3pm](time) - [night](time) - book movie at [night](time) - [4pm](time) - book movie at [4pm](time) - [afternoon](time) - book movie at [afternoon](time)
intents: - greet - goodbye - thanks - deny - joke - name - inform_item - inform_package - inform_time - request_management - request_search - inform_current_phone - inform_other_phone - book_movie_name - inform_time - inform_weekday - inform_ticket_number - inform_movie_name
Next, list the names of all actions.Action is a bot action in rasa that responds to user input.In task scenarios, most actions of a bot are asking for information (slots, entities).
Template, custom function action action action
What do you want to do?Questioning intent
What movie do you want to see and ask for the name of the movie
How many tickets do you want to ask for
When do you want to ask
Function Complete Order
actions: - utter_name - utter_thanks - utter_greet - utter_goodbye - action_joke - utter_ask_morehelp - utter_ask_package - utter_ack_management - action_searchconsume - utter_help - utter_ask_month - utter_givevolumn - utter_ask_ticket_number - utter_ask_weekday - utter_ask_time - utter_ask_movie_name - utter_book_ticket - action_book_ticket templates: utter_name: - text: "Hey there! Tell me your name." utter_greet: - text: "Nice to you meet you {name}. How can I help?" utter_goodbye: - text: "Talk to you later!" utter_thanks: - text: "My pleasure." utter_help: - text: " Hi,How can I help?" utter_givevolumn: - text: "The volume used in {time} is 200mb/1024mb" utter_ask_ticket_number: - text: "Can you tell me the ticket_number?" utter_ask_weekday: - text: "Can you tell me the weekday?" utter_ask_time: - text: "Can you tell me the time?" utter_ask_movie_name: - text: "Can you tell me the movie_name?" utter_book_ticket: - text: "I finish booking of {movie_name} at{time} {weekday}"
Then define the name and type of the slot.Name, type of entity.Slot should, in principle, be a subset of entity, and sara's nlu module extracts entity and tracker decides that slots need not be filled in.
entities: - name - item - time - phone_number - price - movie_name - ticket_number - weekday slots: name: type: text item: type: text time: type: text phone_number: type: text price: type: text ticket_number: type: text weekday: type: text movie_name: type: text
The data above is populated in domain.yml.
Then enter the task flow in story.md in the following format
##Order a movie ticket
*Reserve a movie ticket
-Ask for the name of the movie
*Report movie name
-Question votes
*Number of reported votes
-Ask Time
*Reporting time
-Complete the order
Or join a different process
##Question Intent+Reserve a movie ticket
*Hello
-Interrogation intent
*Reserve a movie ticket
-Ask for the name of the movie
*Report movie name
-Question votes
*Number of reported votes
-Ask Time
*Reporting time
-Complete the order
## story_book_ticket * greet - utter_help * book_movie_name - utter_ask_time * inform_time - utter_ask_weekday * inform_weekday - utter_ask_ticket_number * inform_ticket_number - utter_ask_movie_name * inform_movie_name - utter_book_ticket ## story_book_ticket2 * book_movie_name - action_book_ticket * inform_ticket_number - action_book_ticket * inform_weekday - action_book_ticket * inform_time - action_book_ticket
Based on these two files, RASA core models can be trained to determine action s.
train-core: python -m rasa_core.train -d domain.yml -s data/stories.md -o models/current/dialogue -c policies.yml
Then prepare the intent corpus file nlu.md
Inside, put the text for each intent, and mark the entity and entity names.
as
## intent: Order a movie ticket
-I want to see [Xman1](movie_name)
-I want to see [Xman1](movie_name)
-Help me order [Xman1](movie_name)
-Help me order [Xman2](movie_name)
nlu.md is used to train the nlu model.
train-nlu: python -m rasa_nlu.train -c nlu_config.yml --data data/nlu_data.md -o models --fixed_model_name nlu --project current --verbose