Closed Daniyaldehleh closed 3 years ago
Hi @danieldhz, sorry for the delayed response, unfortunately we do not have a sample skill template to showcase timers API in the skill, but you can refer the official docs.
Its easy as just adding a new service client(add timer_management_service_client) on your request handlers and calling the relevant APIs with its parameters.
Let us know if you are stuck or need any help with this.
Hi @Shreyas-vgr !
You are my herooo! I cannot believe I am talking to you, an amazon's Alexa developer for the python community!!!
I have been working day and night to build an Alexa timer for 3 and a half weeks, however; I have been just getting bugged out due to lack of documentation and support as you mentioned. Thus, I am hoping we can get this working so this can be used as a copy paste template for future developers.
I have finally come down to this finalized code, after days of StackOverflow, alexa discussion forum, and cold calling every developer i know:
timer = {
"duration": "PT15S",
"timerLabel": "Change name",
"creationBehavior": {
"displayExperience": {
"visibility": "VISIBLE"
}
},
"triggeringBehavior": {
"operation": {
"type": "ANNOUNCE",
"textToAnnounce": [
{
"locale": "en-US",
"text": "Break time"
}
]
},
"notificationConfig": {
"playAudible": True
}
}
}
class LaunchRequestHandler(AbstractRequestHandler):
def can_handle(self, handler_input):
return ask_utils.is_request_type("LaunchRequest")(handler_input),ask_utils.is_request_type("AMAZON.YesIntent")(handler_input), ask_utils.is_request_type("AMAZON.NoIntent")(handler_input)
def handle(self, handler_input):
accessToken= ask_sdk_core.utils.get_api_access_token
rb = handler_input.response_builder
request_envelope = handler_input.request_envelope
permissions = request_envelope.context.system.user.permissions
if not (permissions and permissions.consent_token):
logging.info("user hasn't granted reminder permissions")
return (
rb
.add_directive(
SendRequestDirective(
name="AskFor",
payload={
"@type": "AskForPermissionsConsentRequest",
"@version": "1",
"permissionScope": "alexa::alerts:timers:skill:readwrite",
},
token=""
)
)
.response
)
else:
speak_output = "would you like to set the timer for 20 minutes?"
if ask_utils.is_request_type("AMAZON.YesIntent")(handler_input):
options = {"Authorization": "Bearer " + accessToken,
"Content-Type": "application/json"}
return (
requests.post("https://api.amazonalexa.com/v1/alerts/timers", timer, options)
.speak("timer set for 20 seconds")
)
Error: I am actually not getting one but Alexa keep on saying "There was a problem with the requested skill's response"
The permission works. However, I am not sure how to fix the current error. Please let me know if I am prone to running into other bugs that haven't caught my eyes yet.
Hi @danieldhz, sorry to hear you struggling to get this timers API working.
I created a sample timer skill on Python, based on the docs references I had provided earlier and also a similar node.js implementation.
You can refer to this sample skill and please note to add permissions for timers in developer console before you test in on a device. Let me know if you need any help.
HI @Shreyas-vgr You are "Champion". The python community is fortunate to have you. Thanks for building Timer with LAUNCH_TASK. May I know how we can connect a function to it? "text": "Timer elapsed. Would you like to launch {continueWithSkillName}?" I believe we have to build a separate handler, to be called once the timer is over. However, could you please guide us on how to connect that handler to timer JSON? I am trying to call another timer, once the first one is over if user input is positive.
Hi @danieldhz, you can refer to this doc on how to create custom tasks.
Hi @Shreyas-vgr I was actually reading it multiple times. From my understanding you have to
timer_request = {
"duration": "PT15S",
"timerLabel": "My Task Timer",
"creationBehavior": {
"displayExperience": {
"visibility": "VISIBLE"
}
},
"triggeringBehavior": {
"operation": {
"type": "LAUNCH_TASK",
"textToConfirm": [{
"locale": "en-US",
"text": "Timer elapsed. Would you like to launch {continueWithSkillName}?"
}],
"task": {
"name": "testname", --> ADD NEW INTENT NAME HERE
"version": "1",
}
},
"notificationConfig": {
"playAudible": True
}
}
}
Am i right? or am I missing anything?
Hi @danieldhz, from my understanding you need to create an another skill with custom task defined and registered on it and it should be available to be triggered by Alexa through a timer trigger behavior for examples. reference docs
Hi @Shreyas-vgr That was what I was trying to not believe and hence I asked you. As it doesn't make sense why you have to build a whole new skill and not be able to just do it locally cause not only it would be more time consuming for the developer but also cause "interruption" for the user. As an example, if this was a cooking skill, and required 5 or more times, would we have to create 5 skills?
Hi @danieldhz, sorry for the confusion.
You can trigger tasks on existing skill too. 1) Create a new Custom Task: https://developer.amazon.com/en-US/docs/alexa/custom-skills/implement-custom-tasks-in-your-skill.html#create-a-task-definition-file 2) Create a handler for launch requests that come in for that new custom task: https://developer.amazon.com/en-US/docs/alexa/custom-skills/implement-custom-tasks-in-your-skill.html#implement-task-functionality-in-an-aws-lambda-function 3) Register the Custom Task with your skill: https://developer.amazon.com/en-US/docs/alexa/custom-skills/implement-custom-tasks-in-your-skill.html#make-your-task-available-to-other-skills 4) Create a Timer type of Launch Task, with the Operation/Task elements containing the Name & Version of the newly created custom task (as well as any custom 'input' params desired to pass back to the skill when it is launched).
@Shreyas-vgr Thanks for the clarity & the good news. This should do the job :)
Hi @Shreyas-vgr Fortunately, I've finally built the model. Thus, no more debugging question. Instead, I would just like to know if its possible to open the timer session after the timer ends to minimize user friction. If so, how? As after the would you like to {continuewithskillname}"? no sessions get opened for user confirmation nor does the confirmation text gets read repo
Hi @danieldhz, sorry for the delayed response, it is great to hear you were able to build the model. I will redirect all your questions and concerns to the Timers API service team and try to get all answers for you. Do you mind sharing your customer ID of the account you are building and developing the skill? It would be very useful for us to filter out your logs from service side and triage it. https://developer.amazon.com/settings/console/mycid -- Link to obtain the customerID
Hi @Shreyas-vgr Thank you so much for getting back to me!! I really appreciate being forwarded to the Timer API team, as for the past week I have been just forwarded from one developer to another as they couldn't figure out the problem. In fact, debugging a timer API is like mission impossible, as you don't get a responding dev console but just echo device to try it on. My client id is as follows: A31UCTNSZ2ATJ7 The skill is called Timer Template I've also prepared for them a small README file for their convenience.
@Shreyas-vgr May I know when & where can I expect a reply from your respectful team? As well as, would you mind your or your team translating crucial Alexa payment page into python too?
Hi @danieldhz, I have raised your issue and shared your Customer ID and Github repo for the service team to look into the issue. I will reach out to you once I get back an answer from them:)
Regarding Alexa Payment Page, since it is a feature request and not related to this one, I suggest you to create another issue and I will forward the same to the respective team.
Hi @Shreyas-vgr Thanks again for doing that! Look forward to hearing from you.
@Shreyas-vgr quick question: in the doc it recommended me to add tasks/CountDown.1.json under skill-package folder. However, as you know skill-package is already embedded in the ask dev console. Thus, I have no choice to only upload contents of lambda folder to was or else I will get "Lambda can't find file lambda_function.py". Do you know what's the way around it?
@Shreyas-vgr Hi Shreya!
Hope you had an awesome weekend!
Sorry for the subsequent message. I would just like to know if you got any updates? As I am hoping to submit my skill for the exciting hackathon and such a bug is really bottlenecking production.
Hi @danieldhz, Sorry for the delay, but the service team is still analyzing the root cause for the failure, will update as soon as I get a response :)
quick question: in the doc it recommended me to add tasks/CountDown.1.json under skill-package folder. However, as you know skill-package is already embedded in the ask dev console. Thus, I have no choice to only upload contents of lambda folder to was or else I will get "Lambda can't find file lambda_function.py". Do you know what's the way around it?
You can use our ASK-CLI tool as mentioned in the docs to update skill-package.
Hi @Shreyas-vgr Thanks for the update! No worries, I am sure your team would figure it out so I can participate in the hackathon that I have been waiting for the whole summer :)
Hi @danieldhz, service team have fixed the errors causing the issue, can you please try again invoking your timer skill and feel free to comment here or open a new ticket following the template provided thanks.
Hi @Shreyas-vgr you've made my week even though I no longer can make it to the hackathon. Unless the connected timer API goes well on the first try.
My current issue:
I believe the \ in the
return is_request_type("LaunchRequest")(handler_input)\
and handler
is a spelling mistake?
Is it necessary to have the return is_request_type("LaunchRequest")
even though if it's not going to be launch intent?
response_builder.add_directive(CompleteTaskDirective(...))
shall I leave it as handler_input.response_builder.add_directive(CompleteTaskDirective())
or handler_input.response_builder.add_directive(CompleteTaskDirective(status, result))
?
also when I ask deployed I got: ==================== Deploy Skill Metadata ====================
[Error]: {
"skill": {
"resources": [
{
"action": "UPDATE",
"info": [
{
"message": "No change in resource and its dependencies detected. Resource version is up to date with imported package version. Update skipped."
}
],
"name": "Manifest",
"status": "ROLLBACK_SUCCEEDED"
},
{
"action": "CREATE",
"errors": [
{
"message": "InvalidTaskManifestEntry: Your skill defines tasks that are not declared in the manifest: <[amzn1.ask.skill.8284d645-761c-4ebc-..5142ee412bb5.CountDown/1]>."
}
],
"name": "TaskDefinitions",
"status": "FAILED"
}
],
"skillId": "amzn1.ask.skill.8284d645-761c-..-9fe8-5142ee412bb5"
},
"status": "FAILED"
}
Also, the timer skill connection is not working despite following every protocol. I am not sure if your team fixed it yet. The worst thing is that I don't even know how to debug such a complex timer functionality since timers can be only tested on echo.
@DaniyalDhz are you still facing this issue ? I know the service team fixed some issues related to this went you raised the issue here.
@Shreyas-vgr Thanks for the follow up. I just moved on.
Hi There,
Is there any way where we can have a template for calling a timer via alexa's API in python? I would really really appreciate it. As well as, it would be best if in that template it shows how we can follow up on a timer with another timer via Launch_Task.