I am desperate here, I create a simple form, which will ask the weight, send address and receive address then calculate the shipping fee. When I run rasa shell --debug
, nlu model can detect entities correctly. However, the slots are not filled. I have imitated formbot example to write stories, actions, … but still not working
from typing import Dict, Text, Any, List, Union, Optional
from rasa_sdk import Tracker, Action from rasa_sdk.executor import CollectingDispatcher from rasa_sdk.forms import FormAction
class PriceForm(FormAction): def name(self) → Text: “”“Unique identifier of the form”“”
return "price_form" @staticmethod def required_slots(tracker:Tracker) -> List[Text]: """A list of required slots that the form has to fill""" return ["from_address", "destination_address", "weight"] def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]: """A dictionary to map required slots to - an extracted entity - intent: value pairs - a whole message or a list of them, where a first match will be picked """ return { "from_address": self.from_entity(entity= "from_address", intent = "hoi_phi_giao_hang"), "destination_address": self.from_entity(entity= "destination_address", intent = "hoi_phi_giao_hang"), "weight": self.from_entity(entity= "weight", intent = "hoi_phi_giao_hang"), } def submit( self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any], ) -> List[Dict]: """Define what the form has to do after all required slots are filled """ # utter submit template dispatcher.utter_template("utter_submit", tracker) return []
My stories file
happy hoi_phi_giao_hang
- greet
- utter_greet
- hoi_phi_giao_hang
- price_form
- form{“name”: “price_form”}
- form{“name”: null}
- utter_tinh_phi_giao_hang
- thank
- utter_thank
- utter_additional_help
- deny
- utter_thank
contains(“<!–”) ## unhappy hoi_phi_giao_hang
- hoi_phi_giao_hang
- price_form
- form{“name”: “price_form”}
- chitchat
- utter_chitchat
- price_form
- form{“name”: null}
- utter_tinh_phi_giao_hang
- thank
- utter_thank contains(“–>”)
very unhappy hoi_phi_giao_hang
- hoi_phi_giao_hang
- price_form
- form{“name”: “price_form”}
- chitchat
- utter_chitchat
- price_form
- chitchat
- utter_chitchat
- price_form
- chitchat
- utter_chitchat_2
- price_form
- form{“name”: null}
- utter_tinh_phi_giao_hang
- thank
- utter_thank
stop but continue hoi_phi_giao_hang
- greet
- utter_greet
- hoi_phi_giao_hang
- price_form
- form{“name”: “price_form”}
- deny
- utter_ask_continue
- affirm
- price_form
- form{“name”: null}
- utter_tinh_phi_giao_hang
- thank
- utter_thank
stop and really stop path
- greet
- utter_greet
- hoi_phi_giao_hang
- price_form
- form{“name”: “price_form”}
- deny
- utter_ask_continue
- deny
- action_deactivate_form
- form{“name”: null}
chitchat stop but continue path
- hoi_phi_giao_hang
- price_form
- form{“name”: “price_form”}
- chitchat
- utter_chitchat
- price_form
- deny
- utter_ask_continue
- affirm
- price_form
- form{“name”: null}
- utter_tinh_phi_giao_hang
- thank
- utter_thank
- utter_additional_help
- deny
- utter_goodbye
stop but continue and chitchat path
- greet
- utter_greet
- hoi_phi_giao_hang
- price_form
- form{“name”: “price_form”}
- deny
- utter_ask_continue
- affirm
- price_form
- chitchat
- utter_chitchat
- price_form
- form{“name”: null}
- utter_tinh_phi_giao_hang
- thank
- utter_thank
My domain file:
intents:
- affirm
- deny
- greet
- help
- goodbye
- thank
- swearing
- kiem_tra_don
- giuc_giao_hang
- chitchat: use_entities:
- hoi_phi_giao_hang: use_entities:
- buu_cuc_gan_nhat
- dang_ki
entities:
- date
- order_code
- weight
- from_address
- destination_address
- phone_number
- local_address
slots: order_code: type: unfeaturized auto_fill: False weight: type: unfeaturized auto_fill: False from_address: type: unfeaturized auto_fill: False destination_address: type: unfeaturized auto_fill: False requested_slot: type: unfeaturized
templates: utter_ask_continue: - text: “Bạn có muốn tiếp tục ko ?” utter_ask_from_address: - text: “Vui lòng nhập địa chỉ gửi hàng?” utter_ask_destination_address: - text: “Vui lòng nhập địa chỉ giao hàng?” utter_ask_weight: - text: “Vui lòng nhập cân nặng?” utter_chitchat: - text: “Bạn có cần giúp gì liên quan đến đơn hàng, đăng kí và giao hàng nữa không ạ ?” utter_chitchat_2: - text: “I said stop fucking aroung, are you deaf ?. If you are not well educated enough to understand it let me translate it for you since I’m a nice bot\nBạn có cần giúp gì liên quan đến đơn hàng, đăng kí và giao hàng nữa không ạ ?” utter_calculating: - text: “Calculating…” utter_greet: - text: “Chào bạn! Tôi là chatbot của GHTK” utter_help: - text: “Bạn muốn GHTK trợ giúp điều gì?” utter_additional_help: - text: “Bạn muốn GHTK trợ giúp điều gì nữa không ạ?” utter_goodbye: - text: “GHTK rất vui được phục vụ bạn. Tạm biệt!” utter_thank: - text: “Hihi . Không có gì!” utter_swearing: - text: “Watch your language ” utter_kiem_tra_don:
- text: “GHTK đã ghi nhận mã đơn {order_code}. Nhưng thật tiếc chức năng vẫn chưa hoàn thiện!” utter_giuc_giao_hang: - text: “GHTK đang hoàn thiện chức năng giục giao hàng. Bạn thông cảm!” utter_tinh_phi_giao_hang: - text: “GHTK xác nhận tính phí giao hàng dựa những thông tin sau: \n - địa chỉ gửi: {from_address}\n - địa chỉ nhận: {destination_address}\n - cân nặng: {weight}\n” utter_buu_cuc_gan_nhat: - text: “GHTK đang hoàn thiện chức năng tìm bưu cục tại địa điểm {local_address}. Bạn thông cảm!” utter_dang_ki: - text: “GHTK đang hoàn thiện chức năng đăng kí. Bạn thông cảm!” utter_ask_order_code: - text: "Bạn vui lòng cung cấp mã đơn gồm 9 chữ số: " utter_submit: - text: “Hoàn tất” utter_wrong_order_code: - text: “Mã đơn có gì đó sai sai”
actions:
- utter_greet
- utter_help
- utter_goodbye
- utter_thank
- utter_chitchat
- utter_swearing
- utter_kiem_tra_don
- utter_giuc_giao_hang
- utter_buu_cuc_gan_nhat
- utter_dang_ki
- utter_tinh_phi_giao_hang
- utter_ask_order_code
- utter_ask_weight
- utter_ask_from_address
- utter_ask_destination_address
- utter_submit
- utter_wrong_order_code
- utter_calculating
- utter_additional_help
- utter_ask_continue
- utter_chitchat_2
forms:
- price_form
My config file:
language: “vi”
pipeline:
- name: “nlu.tokenizers.whitespace_tokenizer.WhitespaceTokenizer”
- name: “RegexFeaturizer”
- name: “CRFEntityExtractor”
- name: “EntitySynonymMapper”
- name: “CountVectorsFeaturizer” analyzer: ‘char’ min_df: 1 max_df: 1.0 min_ngram: 1 max_ngram: 5
- name: “EmbeddingIntentClassifier” “epochs”: 10 policies:
- name: FallbackPolicy
- name: MemoizationPolicy
- name: KerasPolicy “epochs”: 10
- name: FormPolicy
- name: MappingPolicy