I am trying to set the slot value using custom action as user id and use that for the follow-up conversation.
Logs from Action Server:
(newenv) (base) C:\workspace\rasa\credit-demo>rasa run actions
2022-04-07 16:44:22 INFO rasa_sdk.endpoint - Starting action endpoint server...
2022-04-07 16:44:22 INFO rasa_sdk.executor - Registered function for 'action_conversation'.
2022-04-07 16:44:22 INFO rasa_sdk.executor - Registered function for 'action_create_application'.
2022-04-07 16:44:22 INFO rasa_sdk.endpoint - Action endpoint is up and running on http://0.0.0.0:5055
450121887ed44063a88726ffbc5002ce
Logs from Rasa Shell
? The bot wants to run 'action_conversation', correct? Yes
2022-04-07 16:46:24 ERROR rasa.core.processor - Encountered an exception while running action 'action_conversation'.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.
Traceback (most recent call last):
File "c:\workspace\rasa\newenv\lib\site-packages\rasa\core\processor.py", line 773, in _run_action
output_channel, nlg, temporary_tracker, self.domain
File "c:\workspace\rasa\newenv\lib\site-packages\rasa\core\actions\action.py", line 689, in run
self._validate_action_result(response)
File "c:\workspace\rasa\newenv\lib\site-packages\rasa\core\actions\action.py", line 616, in _validate_action_result
raise e
File "c:\workspace\rasa\newenv\lib\site-packages\rasa\core\actions\action.py", line 607, in _validate_action_result
validate(result, self.action_response_format_spec())
File "c:\workspace\rasa\newenv\lib\site-packages\jsonschema\validators.py", line 541, in validate
cls(schema, *args, **kwargs).validate(instance)
File "c:\workspace\rasa\newenv\lib\site-packages\jsonschema\validators.py", line 130, in validate
version: "2.0"
intents:
- greet
- goodbye
- affirm
- deny
- mood_great
- mood_unhappy
- bot_challenge
- inform
- create_application:
use_entities: []
entities:
- cwrk_id
- reln_nbr
- ca_nbr
slots:
cwrk_id:
type: text
influence_conversation: true
reln_nbr:
type: text
influence_conversation: false
ca_nbr:
type: text
influence_conversation: false
responses:
utter_greet:
- text: "Hey! I am your Credit Assistant!"
utter_cheer_up:
- text: "Here is something to cheer you up:"
image: "https://i.imgur.com/nGF1K8f.jpg"
utter_did_that_help:
- text: "Did that help you?"
utter_happy:
- text: "Great, carry on!"
utter_goodbye:
- text: "Bye"
utter_iamabot:
- text: "I am a bot, powered by Rasa."
utter_help:
- text: "I can help you managing credit system. \nYou can ask me things like:\
\ \n- Initiate Credit Application \n- Relationship Dashboard"
utter_ca_created:
- text: "Successfully created CA with #{ca_nbr} for {reln_nbr}."
utter_no_cwrk_id:
- text: "Sorry, no citi worker has set"
utter_ask_cwrk_id:
- text: "What is your Citi worker ID?"
utter_ask_reln_nbr:
- text: "For which relationship you want to create credit application?"
actions:
- action_conversation
- action_create_application
forms:
create_application_form:
required_slots:
reln_nbr:
- type: from_entity
entity: reln_nbr
- intent:
- inform
- create_application_form
type: from_text
session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: true
config:
store_entities_as_slots: false
# Configuration for Rasa NLU.
# https://rasa.com/docs/rasa/nlu/components/
language: en
pipeline:
# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
# # If you'd like to customize it, uncomment and adjust the pipeline.
# # See https://rasa.com/docs/rasa/tuning-your-model for more information.
- name: WhitespaceTokenizer
- name: RegexFeaturizer
- name: LexicalSyntacticFeaturizer
- name: CountVectorsFeaturizer
- name: CountVectorsFeaturizer
analyzer: char_wb
min_ngram: 1
max_ngram: 4
- name: DIETClassifier
epochs: 100
- name: FallbackClassifier
threshold: 0.3
# Configuration for Rasa Core.
# https://rasa.com/docs/rasa/core/policies/
# # No configuration for policies was provided. The following default policies were used to train your model.
# # If you'd like to customize them, uncomment and adjust the policies.
# # See https://rasa.com/docs/rasa/policies for more information.
policies:
- name: AugmentedMemoizationPolicy
- name: TEDPolicy
epochs: 40
- name: RulePolicy
core_fallback_threshold: 0.4
core_fallback_action_name: "action_default_fallback"
enable_fallback_prediction: True
"""Custom actions"""
import os
from typing import Any, Text, Dict, List
import logging
from dateutil import parser
import sqlalchemy as sa
from rasa_sdk.interfaces import Action
from rasa_sdk import Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.events import SlotSet
class ActionConversation(Action):
"""Set Sender ID as CWRK ID if its' available."""
def name(self) -> Text:
return "action_conversation"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
conversation=tracker.events
print(tracker.sender_id)
return [SlotSet("cwrk_id", tracker.sender_id)]
class ActionCreateApplication(Action):
"""Create Credit Application."""
def name(self) -> Text:
return "action_create_application"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
conversation=tracker.events
print("Creating Credit Application")
return []
""""
class ValidateCreateApplicationForm(FormValidationAction):
def name(self) -> Text:
return "validate_create_application_form"
def validate_cwrk_id(
self,
slot_value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
return {"cwkr_id": slot_value}
def validate_reln_nbr(
self,
slot_value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
return {"reln_nbr": slot_value}
"""