I've built a timer Api call.
timer_request_1 = {
"duration": "PT15S",
"timerLabel": "Change name",
"creationBehavior": {
"displayExperience": {
"visibility": "VISIBLE"
}
},
"triggeringBehavior": {
"operation": {
"type": "ANNOUNCE",
"textToAnnounce": [
{
"locale": "en-US",
"text": "Would you like to proceed with the 40 minutes timer?"
}
]
},
"notificationConfig": {
"playAudible": False
}
}
}
REQUIRED_PERMISSIONS = ["alexa::alerts:timers:skill:readwrite"]
class TimerIntentHandler(AbstractRequestHandler):
def can_handle(self, handler_input):
return ask_utils.is_intent_name("TimerIntent")(handler_input)
def handle(self, handler_input):
permissions = handler_input.request_envelope.context.system.user.permissions
if not (permissions and permissions.consent_token):
return (
handler_input.response_builder
.speak("Please give permissions to set timers using the alexa app.")
.set_card(
AskForPermissionsConsentCard(permissions=REQUIRED_PERMISSIONS)
)
.response
)
timer_service = handler_input.service_client_factory.get_timer_management_service()
timer_response = timer_service.create_timer(timer_request)
if str(timer_response.status) == "Status.ON":
session_attr = handler_input.attributes_manager.session_attributes
if not session_attr:
session_attr['lastTimerId'] = timer_response.id
speech_text = 'Your 20 minutes timer has started!.'
return (
handler_input.response_builder
.speak(speech_text)
.response
.ask("Would you like to proceed x task?")
)
else:
speech_text = 'Timer did not start'
return (
handler_input.response_builder
.speak(speech_text)
.response
)
Next, I have followed the doc to:
- Create a new Custom Task:doc
- Create a handler for launch request doc
- Register the Custom Task doc
- Added LAUNCH_TASK with the name & version of the created custom task.
However, once user says stop to the timer, Alexa doesn't proceed with the countdown task. My intuition is that either timer API is not connected to the task despite following the protocol or Alexa shutdowns down when user says "stop" even though it shouldn't be the case when playaudio is True per the doc. Nevertheless, you are the expert. Does anyone know what I am missing?
My goal is to make a cookbook timer template in python as I believe it would be really helpful for python developers and could help with a lot of delicious meals & desserts to be cooked with Alexa :))
You can access the Repo here too.
Please help me out for the love of food :D