Last active
July 6, 2020 14:48
-
-
Save jmcgill/87e7e54c486e303fb283dd789850b829 to your computer and use it in GitHub Desktop.
RASA / Duckling Form example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Dict, Text, Any, List, Union, Optional | |
from rasa_sdk import Tracker | |
from rasa_sdk.executor import CollectingDispatcher | |
from rasa_sdk.forms import FormAction | |
class BudgetForm(FormAction): | |
def name(self) -> Text: | |
return "budget_form" | |
@staticmethod | |
def required_slots(tracker: Tracker) -> List[Text]: | |
return ["month"] | |
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]: | |
return { | |
"month": [ | |
self.from_entity(entity="time"), | |
self.from_text() | |
], | |
} | |
def submit(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any],) -> List[Dict]: | |
dispatcher.utter_message(template="utter_submit") | |
return [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
language: en | |
pipeline: | |
- name: WhitespaceTokenizer | |
- name: CRFEntityExtractor | |
- name: EntitySynonymMapper | |
- name: CountVectorsFeaturizer | |
token_pattern: (?u)\b\w+\b | |
- name: EmbeddingIntentClassifier | |
- name: DucklingHTTPExtractor | |
url: http://localhost:8000 | |
dimensions: | |
- time | |
policies: | |
- name: FallbackPolicy | |
- name: MemoizationPolicy | |
- name: FormPolicy | |
- name: MappingPolicy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
session_config: | |
session_expiration_time: 60.0 | |
carry_over_slots_to_new_session: true | |
intents: | |
- budget | |
entities: | |
- month | |
- time | |
slots: | |
month: | |
type: unfeaturized | |
responses: | |
utter_default: | |
- text: I'm sorry, I don't understand | |
utter_ask_month: | |
- text: What month do you want to budget for? | |
utter_slots_values: | |
- text: Let's make a budget for {month} | |
utter_submit: | |
- text: Thanks | |
utter_hi: | |
- text: Hello! | |
actions: | |
- utter_ask_month | |
- utter_default | |
- utter_submit | |
- utter_slots_values | |
- utter_hi | |
forms: | |
- budget_form |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## intent:greet | |
- Hi | |
- Hey | |
- Hi bot | |
- Hey bot | |
- Hello | |
- Good morning | |
- hi again | |
- hi folks | |
- hi Mister | |
- hi pal! | |
- hi there | |
- greetings | |
- hello everybody | |
- hello is anybody there | |
- hello robot | |
- hallo | |
- heeey | |
- hi hi | |
- hey | |
- hey hey | |
- hello there | |
- hi | |
- hello | |
- yo | |
- hola | |
- hi? | |
- hey bot! | |
- hello friend | |
- march | |
- hi | |
## intent:budget | |
- budget | |
- plan | |
- I'd like to budget | |
- I'd like to set a budget | |
- resolve my budget | |
- I'd like to make a budget | |
- I'd like to budget for [january](time) | |
- I'd like to budget for [next month](time) | |
- let's budget [this month](time) | |
- budget for [march](time) | |
- budget for [next month](time) | |
- budget for [today](time) | |
- let's budget for [january](time) | |
- can you help me budget? | |
- do you budget? | |
- I want to budget | |
- budgeting is what I am here for | |
- let's do some budgeting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## greet | |
* greet | |
- utter_hi | |
## budget month | |
* budget | |
- budget_form | |
- form{"name": "budget_form"} | |
- form{"name": null} | |
- utter_slots_values | |
## budget with month | |
* budget{"time": "january"} | |
- budget_form | |
- form{"name": "budget_form"} | |
- form{"name": null} | |
- utter_slots_values |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment