You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Features like like PDF Attachment, Dropdown, etc. will be added in Rasa Chatbot Widget 2.0 which is already present inside Chat Widget 1.0. And Inside Chatbot Widget 1.0 after pdf is render in chatbot the buttons is not showing.
actions.py
classActionGetCertificate(Action):
defname(self) ->Text:
return"action_get_certificate"defrun(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) ->List[Dict[Text, Any]]:
# Extract the application_number from the user inputapplication_number=next(tracker.get_latest_entity_values("application_number"), None)
ifapplication_number:
iflen(application_number) ==12orlen(application_number) ==13:
certificate_data=self.get_certificate(application_number)
ifcertificate_data:
# Convert byte array into PDFpdf_data=io.BytesIO(certificate_data)
# Save the PDF file into a folderfolder_path="ui/static/pdf/"# Set the path to the folderfile_name=f"{application_number}.pdf"# Set the desired file namefile_path=os.path.join(folder_path, file_name)
withopen(file_path, "wb") aswfile:
wfile.write(pdf_data.getvalue())
# Pdf URLpdf_url=f'static/pdf/{application_number}.pdf'data= {
"payload": "pdf_attachment",
"title": application_number, # Set the title as the application number"url": pdf_url, # Set the url as the pdf_data object
}
dispatcher.utter_message(text="Here is your pdf", json_message=data)
else:
dispatcher.utter_message(text="Invalid application number. Please try again.")
else:
dispatcher.utter_message(text="The application number should be exactly 12 or 13 characters long.")
else:
dispatcher.utter_message(text="I'm sorry, I didn't get the application number. Please try again.")
return []
defget_certificate(self, application_number: str) ->bytes:
wsdl_url="http://localhost:42512/test?WSDL"# Replace with your web service WSDL URLclient=Client(wsdl_url)
response=client.service.GetCertificate(ApplicationNo=application_number)
returnresponse
stories.yml
story: application_status
steps:
intent: greet
action: utter_greet
intent: ask_for_application_details
action: utter_ask_for_application_no
intent: provide_application_number
entities:
application_number
action: action_get_certificate
action: utter_yes_no
story: Greet and continue if user selects "yes"
steps:
action: utter_yes_no
intent: affirm
action: utter_greet
story: Greet and say goodbye if user selects "no"
steps:
action: utter_yes_no
intent: deny
action: utter_goodbye
domain.yml
intents:
greet
goodbye
affirm
deny
mood_great
mood_unhappy
bot_challenge
ask_for_application_details
provide_application_number
entities:
application_number
actions:
action_get_certificate
responses:
utter_greet:
text: "Hey! How can I assist you today?"
utter_yes_no:
text: "Do you want to continue?"
buttons:
title: Yes
payload: /affirm
title: No
payload: /deny
utter_ask_for_application_no:
text: "Please provide your application number"
utter_cheer_up:
text: "Here is something to cheer you up:"
image: "static/cub.jpg"
Features like like PDF Attachment, Dropdown, etc. will be added in Rasa Chatbot Widget 2.0 which is already present inside Chat Widget 1.0. And Inside Chatbot Widget 1.0 after pdf is render in chatbot the buttons is not showing.
actions.py
stories.yml
story: application_status
steps:
entities:
story: Greet and continue if user selects "yes"
steps:
story: Greet and say goodbye if user selects "no"
steps:
domain.yml
intents:
entities:
actions:
responses:
utter_greet:
utter_yes_no:
buttons:
payload: /affirm
payload: /deny
utter_ask_for_application_no:
utter_cheer_up:
image: "static/cub.jpg"
utter_did_that_help:
utter_happy:
utter_goodbye:
utter_iamabot:
session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: true
The text was updated successfully, but these errors were encountered: