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 ask_sdk_model.services.ups 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 (
handler_input.response_builder
.speak(speak_output)
.ask(speak_output)
.response
)