Hi,
I have following situation. I have a bot which supports the user creating a ticket for the IT-support. I am using forms for that. First of all, the bot asks the user if they should make the ticket together. If yes, the bot asks for a summary and a description. After that he performs a API POST call to create an issue in jira. If no, the bot only should send a link where the user can find a guide for creating a jira issue.
My form is working fine in some parts. If the users agrees to fill out the form everything is okay, but If the user says no and he just wants the link I run in problems deactivating the form.
Here are some parts of my config:
Rasa Form
class CreateJiraIssue(FormAction):
"""Example of a custom form action"""
def name(self):
"""Unique identifier of the form"""
return "create_jira_issue_form"
@staticmethod
def required_slots(tracker: "Tracker") -> List[Text]:
return ["start_form", "sd_summary", "sd_description"]
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict[Text, Any]]]]:
return {
"start_form":[
self.from_intent(intent="affirm", value=True),
self.from_intent(intent="deny", value=False)
],
"sd_summary":self.from_text(),
"sd_description":self.from_text()
}
def validate_start_form(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
last_intent = tracker.latest_message['intent'].get('name')
if last_intent == 'deny':
confluence_link = 'mylink'
element = {
"template-type": "generic",
"elements": [
{
"flag": "l",
"before": "",
"middle": "",
"after": " findest du eine Anleitung, wie man eine Jira Service-Anfrage erstellt. "
,
"links": [
{
"url": confluence_link,
"title": "Hier"
}
]
}
]
}
dispatcher.utter_custom_json(element)
return self.deactivate()
else:
return {"start_form": "True"}
def submit(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[Dict]:
print("all done")
return [AllSlotsReset()]
Please ignore the custom JSON utterance. This is just my way to send a link to the user with some text.
Domain
actions:
#Utterances
- utter_goodbye
- utter_greet
- utter_you_are_welcome
intents:
- goodbye:
triggers: utter_goodbye
use_entities: []
- greet:
triggers: utter_greet
use_entities: []
- say_thank_you:
triggers: utter_you_are_welcome
use_entities: []
- jira_ask_for_service_request_guide:
use_entities: []
slots:
start_form:
type: unfeaturized
auto_fill: false
sd_summary:
type: unfeaturized
auto_fill: false
sd_description:
type: unfeaturized
auto_fill: false
requested_slot:
type: unfeaturized
responses:
utter_goodbye:
- text: Auf Wiedersehen
- text: Einen schönen Tag noch
- text: Bye Bye
utter_greet:
- text: Hallo, was kann ich für dich tun?
- text: Guten Tag, wie kann ich dir weiterhelfen?
utter_you_are_welcome:
- text: Gern geschehen :)
utter_ask_start_form:
- text: Sollen wir gemeinsam eine Jira Serviceanfrage erstellen?
utter_ask_sd_summary:
- text: Wie lautet der Betreff für deine Service Anfrage?
utter_ask_sd_description:
- text: Bitte schreib jetzt eine aussagekräftige Zusammenfassung.
utter_jira_sd_values:
- text: "Ich habe jetzt alle benötigten Informationen. Hier eine kurze Zusammenfassung:\n
Betreff: {sd_summary}\n
Zusammenfassung: {sd_description}\n\n
Kann ich die Service Anfrage nun abschicken?"
and finally my Stories
## greet + create_jira_issue_form
*greet
- utter_greet
* jira_ask_for_service_request_guide
- create_jira_issue_form
- form{"name":"create_jira_issue_form"}
- form{"name":null}
- utter_jira_sd_values
* say_thank_you
- utter_you_are_welcome
## create_jira_issue_form
* jira_ask_for_service_request_guide
- create_jira_issue_form
- form{"name":"create_jira_issue_form"}
- form{"name":null}
- utter_jira_sd_values
## greet + create_jira_issue_form + deny
* greet
- utter_greet
* jira_ask_for_service_request_guide
- create_jira_issue_form
- form{"name": "create_jira_issue_form"}
- slot{"requested_slot": "start_form"}
* deny
- action_deactivate_form
- form{"name": null}
- slot{"requested_slot": null}
* say_thank_you
- utter_you_are_welcome
The problem happens after the bot aks
“Sollen wir gemeinsam eine Jira Serviceanfrage erstellen?”
if the user says “nein” (no) the bot answers as below (i used rasa shell --debug)
Custom json:
{
"template-type": "generic",
"elements": [
{
"flag": "l",
"before": "",
"middle": "",
"after": " findest du eine Anleitung, wie man eine Jira Service-Anfrage erstellt. ",
"links": [
{
"url": "<mylink>",
"title": "Hier"
}
]
}
]
}
Wie lautet der Betreff für deine Service Anfrage?
Your input ->
The bot should only answer the custom json. However he tries to get the summary from the user with the question “Wie lautet der Betreff für deine Service Anfrage?”
This question should only be raised of the user choosed “ja” (yes).
For testing purpose I just answerd to this with “vielen dank” (thank you very much), as I expected the bot filled the sd_summary-slot
with this value.
It seems the bot did not deactivate the form correctly. In normal situation he should answer “Gern geschehen” (you are welcome).
Can somebody tell my why my bot won´t deactivate the form? He sends the custom json, so he is able to extract the last user intent deny
and normally return self.deactivate()
should work.