I’m having trouble understanding and setting up forms in rasa.
I want to setup a simple form to set appointments with two entities appointment_type
and time
such as doctor's appointment
and 25/11/2020
.
I want to use rasa through the http api so this is my current workflow:
sending a post
request to http://localhost:5005/conversations/100/messages
with the following data:
{"text": "new appointment tomorrow at 11am",
"sender": "user"}
and receive this response:
{
"sender_id": "100",
"slots": {
"appointment_type": null,
"requested_slot": null,
"time": "2020-10-28T11:00:00.000-07:00"
},
"latest_message": {
"intent": {
"id": 2558005979422351271,
"name": "new_appointment",
"confidence": 0.971845269203186
},
"entities": [
{
"start": 16,
"end": 32,
"text": "tomorrow at 11am",
"value": "2020-10-28T11:00:00.000-07:00",
"confidence": 1,
"additional_info": {
"values": [
{
"value": "2020-10-28T11:00:00.000-07:00",
"grain": "hour",
"type": "value"
}
],
"value": "2020-10-28T11:00:00.000-07:00",
"grain": "hour",
"type": "value"
},
"entity": "time",
"extractor": "DucklingEntityExtractor"
}
],
"text": "new appointment tomorrow at 11am",
"message_id": "9a45c379f54a4993b8dc6fc83f594208",
"metadata": {},
"intent_ranking": [
{
"id": 2558005979422351271,
"name": "new_appointment",
"confidence": 0.971845269203186
},
{
"id": -7927597194627343093,
"name": "inform",
"confidence": 0.014766165055334568
},
{
"id": 2143190942195339664,
"name": "bot_challenge",
"confidence": 0.0038445102982223034
},
{
"id": 8480155341338955069,
"name": "new_hello_world",
"confidence": 0.0024878832045942545
},
{
"id": 970287900190489755,
"name": "mood_great",
"confidence": 0.0023573434446007013
},
{
"id": -2088467630623076365,
"name": "affirm",
"confidence": 0.0018784157000482082
},
{
"id": -7169327219185566481,
"name": "greet",
"confidence": 0.001436947495676577
},
{
"id": -5021645415749652793,
"name": "deny",
"confidence": 0.0008943644352257252
},
{
"id": -760644810904088166,
"name": "goodbye",
"confidence": 0.00038150252657942474
},
{
"id": -4637220978992053084,
"name": "mood_unhappy",
"confidence": 0.00010759664291981608
}
],
"response_selector": {
"all_retrieval_intents": [],
"default": {
"response": {
"id": null,
"response_templates": null,
"confidence": 0,
"intent_response_key": null,
"template_name": "utter_None"
},
"ranking": []
}
}
},
"latest_event_time": 1603791118.2023346,
"followup_action": null,
"paused": false,
"events": [
{
"event": "action",
"timestamp": 1603791118.189822,
"name": "action_session_start",
"policy": null,
"confidence": null
},
{
"event": "session_started",
"timestamp": 1603791118.1898315
},
{
"event": "action",
"timestamp": 1603791118.18985,
"name": "action_listen",
"policy": null,
"confidence": null
},
{
"event": "user",
"timestamp": 1603791118.2023199,
"text": "new appointment tomorrow at 11am",
"parse_data": {
"intent": {
"id": 2558005979422351271,
"name": "new_appointment",
"confidence": 0.971845269203186
},
"entities": [
{
"start": 16,
"end": 32,
"text": "tomorrow at 11am",
"value": "2020-10-28T11:00:00.000-07:00",
"confidence": 1,
"additional_info": {
"values": [
{
"value": "2020-10-28T11:00:00.000-07:00",
"grain": "hour",
"type": "value"
}
],
"value": "2020-10-28T11:00:00.000-07:00",
"grain": "hour",
"type": "value"
},
"entity": "time",
"extractor": "DucklingEntityExtractor"
}
],
"text": "new appointment tomorrow at 11am",
"message_id": "9a45c379f54a4993b8dc6fc83f594208",
"metadata": {},
"intent_ranking": [
{
"id": 2558005979422351271,
"name": "new_appointment",
"confidence": 0.971845269203186
},
{
"id": -7927597194627343093,
"name": "inform",
"confidence": 0.014766165055334568
},
{
"id": 2143190942195339664,
"name": "bot_challenge",
"confidence": 0.0038445102982223034
},
{
"id": 8480155341338955069,
"name": "new_hello_world",
"confidence": 0.0024878832045942545
},
{
"id": 970287900190489755,
"name": "mood_great",
"confidence": 0.0023573434446007013
},
{
"id": -2088467630623076365,
"name": "affirm",
"confidence": 0.0018784157000482082
},
{
"id": -7169327219185566481,
"name": "greet",
"confidence": 0.001436947495676577
},
{
"id": -5021645415749652793,
"name": "deny",
"confidence": 0.0008943644352257252
},
{
"id": -760644810904088166,
"name": "goodbye",
"confidence": 0.00038150252657942474
},
{
"id": -4637220978992053084,
"name": "mood_unhappy",
"confidence": 0.00010759664291981608
}
],
"response_selector": {
"all_retrieval_intents": [],
"default": {
"response": {
"id": null,
"response_templates": null,
"confidence": 0,
"intent_response_key": null,
"template_name": "utter_None"
},
"ranking": []
}
}
},
"input_channel": null,
"message_id": "9a45c379f54a4993b8dc6fc83f594208",
"metadata": {}
},
{
"event": "slot",
"timestamp": 1603791118.2023346,
"name": "time",
"value": "2020-10-28T11:00:00.000-07:00"
}
],
"latest_input_channel": null,
"active_loop": {},
"latest_action": {
"action_name": "action_listen"
},
"latest_action_name": "action_listen"
}
then I use the predict
endpoint by sending another post
request to http://localhost:5005/conversations/100/predict
where I receive this response:
{
"scores": [
{
"action": "appointment_form",
"score": 1
},
{
"action": "action_default_fallback",
"score": 0.3
},
{
"action": "...",
"score": 0
},
{
"action": "action_back",
"score": 0
},
{
"action": "action_deactivate_loop",
"score": 0
},
{
"action": "action_default_ask_affirmation",
"score": 0
},
{
"action": "action_default_ask_rephrase",
"score": 0
},
{
"action": "action_hello_world",
"score": 0
},
{
"action": "action_listen",
"score": 0
},
{
"action": "action_restart",
"score": 0
},
{
"action": "action_revert_fallback_events",
"score": 0
},
{
"action": "action_session_start",
"score": 0
},
{
"action": "action_two_stage_fallback",
"score": 0
},
{
"action": "utter_ask_appointment_type",
"score": 0
},
{
"action": "utter_ask_time",
"score": 0
},
{
"action": "utter_cheer_up",
"score": 0
},
{
"action": "utter_did_that_help",
"score": 0
},
{
"action": "utter_goodbye",
"score": 0
},
{
"action": "utter_greet",
"score": 0
},
{
"action": "utter_happy",
"score": 0
},
{
"action": "utter_iamabot",
"score": 0
},
{
"action": "utter_slots_values",
"score": 0
},
{
"action": "utter_submit",
"score": 0
},
{
"action": "validate_appointment_form",
"score": 0
}
],
"policy": "policy_2_RulePolicy",
"confidence": 1,
"tracker": {
"sender_id": "100",
"slots": {
"appointment_type": null,
"requested_slot": null,
"time": "2020-10-28T11:00:00.000-07:00"
},
"latest_message": {
"intent": {
"id": 2558005979422351271,
"name": "new_appointment",
"confidence": 0.971845269203186
},
"entities": [
{
"start": 16,
"end": 32,
"text": "tomorrow at 11am",
"value": "2020-10-28T11:00:00.000-07:00",
"confidence": 1,
"additional_info": {
"values": [
{
"value": "2020-10-28T11:00:00.000-07:00",
"grain": "hour",
"type": "value"
}
],
"value": "2020-10-28T11:00:00.000-07:00",
"grain": "hour",
"type": "value"
},
"entity": "time",
"extractor": "DucklingEntityExtractor"
}
],
"text": "new appointment tomorrow at 11am",
"message_id": "9a45c379f54a4993b8dc6fc83f594208",
"metadata": {},
"intent_ranking": [
{
"id": 2558005979422351271,
"name": "new_appointment",
"confidence": 0.971845269203186
},
{
"id": -7927597194627343093,
"name": "inform",
"confidence": 0.014766165055334568
},
{
"id": 2143190942195339664,
"name": "bot_challenge",
"confidence": 0.0038445102982223034
},
{
"id": 8480155341338955069,
"name": "new_hello_world",
"confidence": 0.0024878832045942545
},
{
"id": 970287900190489755,
"name": "mood_great",
"confidence": 0.0023573434446007013
},
{
"id": -2088467630623076365,
"name": "affirm",
"confidence": 0.0018784157000482082
},
{
"id": -7169327219185566481,
"name": "greet",
"confidence": 0.001436947495676577
},
{
"id": -5021645415749652793,
"name": "deny",
"confidence": 0.0008943644352257252
},
{
"id": -760644810904088166,
"name": "goodbye",
"confidence": 0.00038150252657942474
},
{
"id": -4637220978992053084,
"name": "mood_unhappy",
"confidence": 0.00010759664291981608
}
],
"response_selector": {
"all_retrieval_intents": [],
"default": {
"response": {
"id": null,
"response_templates": null,
"confidence": 0,
"intent_response_key": null,
"template_name": "utter_None"
},
"ranking": []
}
}
},
"latest_event_time": 1603791118.2023346,
"followup_action": null,
"paused": false,
"events": [
{
"event": "action",
"timestamp": 1603791118.189822,
"name": "action_session_start",
"policy": null,
"confidence": null
},
{
"event": "session_started",
"timestamp": 1603791118.1898315
},
{
"event": "action",
"timestamp": 1603791118.18985,
"name": "action_listen",
"policy": null,
"confidence": null
},
{
"event": "user",
"timestamp": 1603791118.2023199,
"text": "new appointment tomorrow at 11am",
"parse_data": {
"intent": {
"id": 2558005979422351271,
"name": "new_appointment",
"confidence": 0.971845269203186
},
"entities": [
{
"start": 16,
"end": 32,
"text": "tomorrow at 11am",
"value": "2020-10-28T11:00:00.000-07:00",
"confidence": 1,
"additional_info": {
"values": [
{
"value": "2020-10-28T11:00:00.000-07:00",
"grain": "hour",
"type": "value"
}
],
"value": "2020-10-28T11:00:00.000-07:00",
"grain": "hour",
"type": "value"
},
"entity": "time",
"extractor": "DucklingEntityExtractor"
}
],
"text": "new appointment tomorrow at 11am",
"message_id": "9a45c379f54a4993b8dc6fc83f594208",
"metadata": {},
"intent_ranking": [
{
"id": 2558005979422351271,
"name": "new_appointment",
"confidence": 0.971845269203186
},
{
"id": -7927597194627343093,
"name": "inform",
"confidence": 0.014766165055334568
},
{
"id": 2143190942195339664,
"name": "bot_challenge",
"confidence": 0.0038445102982223034
},
{
"id": 8480155341338955069,
"name": "new_hello_world",
"confidence": 0.0024878832045942545
},
{
"id": 970287900190489755,
"name": "mood_great",
"confidence": 0.0023573434446007013
},
{
"id": -2088467630623076365,
"name": "affirm",
"confidence": 0.0018784157000482082
},
{
"id": -7169327219185566481,
"name": "greet",
"confidence": 0.001436947495676577
},
{
"id": -5021645415749652793,
"name": "deny",
"confidence": 0.0008943644352257252
},
{
"id": -760644810904088166,
"name": "goodbye",
"confidence": 0.00038150252657942474
},
{
"id": -4637220978992053084,
"name": "mood_unhappy",
"confidence": 0.00010759664291981608
}
],
"response_selector": {
"all_retrieval_intents": [],
"default": {
"response": {
"id": null,
"response_templates": null,
"confidence": 0,
"intent_response_key": null,
"template_name": "utter_None"
},
"ranking": []
}
}
},
"input_channel": null,
"message_id": "9a45c379f54a4993b8dc6fc83f594208",
"metadata": {}
},
{
"event": "slot",
"timestamp": 1603791118.2023346,
"name": "time",
"value": "2020-10-28T11:00:00.000-07:00"
}
],
"latest_input_channel": null,
"active_loop": {},
"latest_action": {
"action_name": "action_listen"
},
"latest_action_name": "action_listen"
}
}
then I trigger the intent new_appointment
by sending a post request with this data:
{
"name": "new_appointment"
}
to http://localhost:5005/conversations/100/trigger_intent
which gives the following response:
{
"tracker": {
"sender_id": "100",
"slots": {
"appointment_type": null,
"requested_slot": "appointment_type",
"time": "2020-10-28T11:00:00.000-07:00"
},
"latest_message": {
"intent": {
"name": "new_appointment"
},
"entities": [],
"text": "EXTERNAL: new_appointment",
"message_id": null,
"metadata": {
"is_external": true
}
},
"latest_event_time": 1603791490.9851916,
"followup_action": null,
"paused": false,
"events": [
{
"event": "action",
"timestamp": 1603791118.189822,
"name": "action_session_start",
"policy": null,
"confidence": null
},
{
"event": "session_started",
"timestamp": 1603791118.1898315
},
{
"event": "action",
"timestamp": 1603791118.18985,
"name": "action_listen",
"policy": null,
"confidence": null
},
{
"event": "user",
"timestamp": 1603791118.2023199,
"text": "new appointment tomorrow at 11am",
"parse_data": {
"intent": {
"id": 2558005979422351271,
"name": "new_appointment",
"confidence": 0.971845269203186
},
"entities": [
{
"start": 16,
"end": 32,
"text": "tomorrow at 11am",
"value": "2020-10-28T11:00:00.000-07:00",
"confidence": 1,
"additional_info": {
"values": [
{
"value": "2020-10-28T11:00:00.000-07:00",
"grain": "hour",
"type": "value"
}
],
"value": "2020-10-28T11:00:00.000-07:00",
"grain": "hour",
"type": "value"
},
"entity": "time",
"extractor": "DucklingEntityExtractor"
}
],
"text": "new appointment tomorrow at 11am",
"message_id": "9a45c379f54a4993b8dc6fc83f594208",
"metadata": {},
"intent_ranking": [
{
"id": 2558005979422351271,
"name": "new_appointment",
"confidence": 0.971845269203186
},
{
"id": -7927597194627343093,
"name": "inform",
"confidence": 0.014766165055334568
},
{
"id": 2143190942195339664,
"name": "bot_challenge",
"confidence": 0.0038445102982223034
},
{
"id": 8480155341338955069,
"name": "new_hello_world",
"confidence": 0.0024878832045942545
},
{
"id": 970287900190489755,
"name": "mood_great",
"confidence": 0.0023573434446007013
},
{
"id": -2088467630623076365,
"name": "affirm",
"confidence": 0.0018784157000482082
},
{
"id": -7169327219185566481,
"name": "greet",
"confidence": 0.001436947495676577
},
{
"id": -5021645415749652793,
"name": "deny",
"confidence": 0.0008943644352257252
},
{
"id": -760644810904088166,
"name": "goodbye",
"confidence": 0.00038150252657942474
},
{
"id": -4637220978992053084,
"name": "mood_unhappy",
"confidence": 0.00010759664291981608
}
],
"response_selector": {
"all_retrieval_intents": [],
"default": {
"response": {
"id": null,
"response_templates": null,
"confidence": 0,
"intent_response_key": null,
"template_name": "utter_None"
},
"ranking": []
}
}
},
"input_channel": null,
"message_id": "9a45c379f54a4993b8dc6fc83f594208",
"metadata": {}
},
{
"event": "slot",
"timestamp": 1603791118.2023346,
"name": "time",
"value": "2020-10-28T11:00:00.000-07:00"
},
{
"event": "user",
"timestamp": 1603791490.9326606,
"metadata": {
"is_external": true
},
"text": "EXTERNAL: new_appointment",
"parse_data": {
"intent": {
"name": "new_appointment"
},
"entities": [],
"text": "EXTERNAL: new_appointment",
"message_id": null,
"metadata": {
"is_external": true
}
},
"input_channel": null,
"message_id": null
},
{
"event": "action",
"timestamp": 1603791490.9797814,
"name": "appointment_form",
"policy": "policy_2_RulePolicy",
"confidence": 1
},
{
"event": "active_loop",
"timestamp": 1603791490.9797873,
"name": "appointment_form"
},
{
"event": "slot",
"timestamp": 1603791490.97979,
"name": "requested_slot",
"value": "appointment_type"
},
{
"event": "slot",
"timestamp": 1603791490.9797928,
"name": "time",
"value": "2020-10-28T11:00:00.000-07:00"
},
{
"event": "slot",
"timestamp": 1603791490.9797945,
"name": "requested_slot",
"value": "appointment_type"
},
{
"event": "bot",
"timestamp": 1603791490.979796,
"metadata": {
"template_name": "utter_ask_appointment_type"
},
"text": "What is the appointment?",
"data": {
"elements": null,
"quick_replies": null,
"buttons": null,
"attachment": null,
"image": null,
"custom": null
}
},
{
"event": "action",
"timestamp": 1603791490.9851916,
"name": "action_listen",
"policy": "policy_2_RulePolicy",
"confidence": 1
}
],
"latest_input_channel": null,
"active_loop": {
"name": "appointment_form",
"is_interrupted": false,
"rejected": false,
"trigger_message": {
"intent": {
"name": "new_appointment"
},
"entities": [],
"text": "EXTERNAL: new_appointment",
"message_id": null,
"metadata": {
"is_external": true
}
}
},
"latest_action": {
"action_name": "action_listen"
},
"latest_action_name": "action_listen"
},
"messages": [
{
"recipient_id": "100",
"text": "What is the appointment?"
}
]
}
there are a few things I don’t understand:
when I trigger the intent I must be doing something wrong as this seems to work correctly on the first round of conversation but after the user replies to What is the appointment?
with doctor's appointment
, the output of the second intent triggering causes the appointment type to be overwritten as EXTERNAL: new_appointment
.
Also, is the FormAction
parameter described in How to Build Your First Rasa Form deprecated or should be used when using custom actions for forms? I only see custom actions using the Actions
parameter in the current documentation so I am confused as to which part is valid for rasa 2 and which is legacy.
Thanks a lot