I’m having a few problems getting a custom action to work and add the result as a slot.
It looks like the action is being called, but SlotSet()
doesn’t seem to update the required slot (the required string is returned from the api and . No error messages apparent. I’ve written other actions for filling in forms that have worked ok.
I want to update a slot called result
with some string information that comes back from an api call. I’
The key aspects are as follows:
Grateful for any help with troubleshooting, as I’m out of ideas.
I’m using rasa==1.3.9
but have tried 1.4.0
too.
in domain.yml
:
entities:
result
slots:
result:
type:text
templates:
utter_result:
- text: Result - {result}
actions:
- action_check_result
actions.py
:
from typing import Dict, Text, Any, List, Union, Optional
from rasa_sdk import Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.forms import FormAction
from rasa_sdk import Action
from rasa_sdk.events import SlotSet
class ActionCheckResult(Action):
def name(self) -> Text:
return "action_check_result"
def run(self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
curr_dict = tracker.slots
curr_json = json.dumps(curr_dict)
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post(RES_URL, data=json, headers=headers)
result = r.text
#tried setting slot in code and returning it, neither works.
#SlotSet("result", str(result))
dispatcher.utter_template('utter_result', tracker)
return [SlotSet("result", result)]
stories.md
:
## happy path
* greet
- action_check_result