Abhishek Gupta avatar image
Abhishek Gupta asked

Alexa fetching user email using Python backend

I am trying to make an Alexa skill using a Python backend. I am using Amazon developer console to create a model and code the backend.I want to retrieve a user email address. I tried many methods but none were working.Everything mentioned online is for Node, and I want to make my backend in Python.

I already gave permission for email in this skill, but I'm unable to fetch email. How can I solve this issue?

import logging
import ask_sdk_core.utils as ask_utils

from ask_sdk_core.skill_builder import SkillBuilder
from ask_sdk_core.dispatch_components import AbstractRequestHandler

from ask_sdk_core.dispatch_components import AbstractExceptionHandler
from ask_sdk_core.handler_input import HandlerInput

from import UpsServiceClient

from ask_sdk_core.api_client import DefaultApiClient

from ask_sdk_model import Response
class EmailIntentHandler(AbstractRequestHandler):
    def can_handle(self, handler_input):
        # type: (HandlerInput) -> bool
        return ask_utils.is_intent_name("EmailIntent")(handler_input)

    def handle(self, handler_input):
        service_client_factory = handler_input.service_client_factory
        ups_service_client = UpsServiceClient(service_client_factory.get_ups_service())
        profile_email = ups_service_client.get_profile_email()
        speak_output = f"Your email is {profile_email}"
        return (
alexapythonalexa skills
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Andy Whitworth avatar image
Andy Whitworth answered

Did you register an API client when creating your skill builder ? You need one to use the service_client_factory.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.