Rasa Core version: 0.10.4
Python version: 3.6.5
Operating system (windows, osx, …): Ubuntu 18.04.1 LTS
Issue: I need to trigger an intent from inside a custom action.
I’m checking if the user has introduced some terms in his/her query. To do that, I’m searching in a JSON file. If I find any of the terms in the query, then I want to run an action, if not, then I need to run a different one.
Content of domain file:
intents:
- defineTerm
- affirm
- default
templates:
utter_confirm:
- "Do you want to see a definition for \"%s\"?"
utter_default:
- "Terms not found"
actions:
- utter_confirm
- utter_default
- actions.MainAction
- actions.RunAction
Content of actions.py file:
class MainAction(Action):
def name(self):
return "take_action"
def run(self, dispatcher, tracker, domain):
terms = my_utils.get_terms(tracker.latest_message.text) # list of valid terms
if not terms:
return[UserUttered(text="/default", intent={"name": "default", "confidence": 1.0})]
else:
message = {"text": domain.templates['utter_confirm'][0]["text"] % ', '.join(terms)}
dispatcher.utter_response(message)
return []
class RunAction(Action):
def name(self):
return "run_action"
def run(self, dispatcher, tracker, domain):
# do some things
return []
Content of stories.md file:
## story1
* defineTerm
- take_action
* affirm
- run_action
## story2a
* defineTerm
- take_action
* default
- utter_default
## story2b
* defineTerm
- take_action
I’ve tried writing either “story2a” or “story2b”, but it doesn’t work properly. It would be good too if I could set it to the end of a story, i.e. make that the bot see the next text introduced by the user as the beginning of a story. Any suggestion?