deeppavlov/utils/alexa/conversation.py
def _handle_intent(self, request: dict) -> dict:
        """Handles IntentRequest Alexa request.

        Args:
            request: Alexa request.
        Returns:
            response: "response" part of response dict conforming Alexa specification.
        """
        intent_name = self.config['intent_name']
        slot_name = self.config['slot_name']

        request_id = request['request']['requestId']
        request_intent: dict = request['request']['intent']

        if intent_name != request_intent['name']:
            log.error(f"Wrong intent name received: {request_intent['name']} in request {request_id}")
            return {'error': 'wrong intent name'}

        if slot_name not in request_intent['slots'].keys():
            log.error(f'No slot named {slot_name} found in request {request_id}')
            return {'error': 'no slot found'}

        utterance = request_intent['slots'][slot_name]['value']
        agent_response = self._act(utterance)

        if not agent_response:
            log.error(f'Some error during response generation for request {request_id}')
            return {'error': 'error during response generation'}

        prediction: RichMessage = agent_response[0]
        prediction: list = prediction.alexa()

        if not prediction:
            log.error(f'Some error during response generation for request {request_id}')
            return {'error': 'error during response generation'}

        response = self._generate_response(prediction[0], request)

        return response
def _handle_intent(self, request: dict) -> dict:
        """Handles IntentRequest Alexa request.

        Args:
            request: Alexa request.
        Returns:
            response: "response" part of response dict conforming Alexa specification.
        """
        intent_name = self.config['intent_name']
        slot_name = self.config['slot_name']

        request_id = request['request']['requestId']
        request_intent: dict = request['request']['intent']

        if intent_name != request_intent['name']:
            log.error(f"Wrong intent name received: {request_intent['name']} in request {request_id}")
            return {'error': 'wrong intent name'}

        if slot_name not in request_intent['slots'].keys():
            log.error(f'No slot named {slot_name} found in request {request_id}')
            return {'error': 'no slot found'}

        utterance = request_intent['slots'][slot_name]['value']
        agent_response = self._act(utterance)

        if not agent_response:
            log.error(f'Some error during response generation for request {request_id}')
            return {'error': 'error during response generation'}

        prediction: RichMessage = agent_response[0]
        prediction: list = prediction.alexa()

        if not prediction:
            log.error(f'Some error during response generation for request {request_id}')
            return {'error': 'error during response generation'}

        response = self._generate_response(prediction[0], request)

        return response
def _handle_intent ( self , request : dict ) -> dict : intent_name = self . config [ 'intent_name' ] slot_name = self . config [ 'slot_name' ] request_id = request [ 'request' ] [ 'requestId' ] request_intent : dict = request [ 'request' ] [ 'intent' ] if intent_name != request_intent [ 'name' ] : log . error ( f"Wrong intent name received: {request_intent['name']} in request {request_id}" ) return { 'error' : 'wrong intent name' } if slot_name not in request_intent [ 'slots' ] . keys ( ) : log . error ( f'No slot named {slot_name} found in request {request_id}' ) return { 'error' : 'no slot found' } utterance = request_intent [ 'slots' ] [ slot_name ] [ 'value' ] agent_response = self . _act ( utterance ) if not agent_response : log . error ( f'Some error during response generation for request {request_id}' ) return { 'error' : 'error during response generation' } prediction : RichMessage = agent_response [ 0 ] prediction : list = prediction . alexa ( ) if not prediction : log . error ( f'Some error during response generation for request {request_id}' ) return { 'error' : 'error during response generation' } response = self . _generate_response ( prediction [ 0 ] , request ) return response
Handles IntentRequest Alexa request.

        Args:
            request: Alexa request.
        Returns:
            response: "response" part of response dict conforming Alexa specification.
Handles IntentRequest Alexa request .