Esempio n. 1
0
    async def process_actions(self, action_call):
        from rasa_sdk.interfaces import Tracker

        action_name = action_call.get("next_action")
        if action_name and action_name.strip():
            logger.debug(f"Received request to run '{action_name}'")

            tracker_json = action_call["tracker"]
            domain = action_call.get("domain", {})
            tracker = Tracker.from_dict(tracker_json)
            dispatcher = CollectingDispatcher()

            events = await ActionProcessor.process_action(
                dispatcher, tracker, domain, action_name)

            if not events:
                events = []

            validated_events = ActionExecutor.validate_events(
                events, action_name)
            logger.debug(f"Finished running '{action_name}'")
            return ActionExecutor._create_api_response(validated_events,
                                                       dispatcher.messages)

        logger.warning("Received an action call without an action.")
        return None
Esempio n. 2
0
def test_event_validation_accepts_dicts_with_event():
    assert ActionExecutor.validate_events([{
        "event": "user"
    }], "myaction") == [{
        "event": "user"
    }]
Esempio n. 3
0
def test_event_validation_fails_on_odd_things(noevent):
    assert ActionExecutor.validate_events([noevent], "myaction") == []