alexa / alexa-skills-kit-sdk-for-python

The Alexa Skills Kit SDK for Python helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
https://developer.amazon.com/en-US/docs/alexa/alexa-skills-kit-sdk-for-python/overview.html
Apache License 2.0
812 stars 206 forks source link

SMAPI - Send string texts/messages to Alexa #150

Closed dadarrel closed 4 years ago

dadarrel commented 4 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[x] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[x] Other... Please describe: Technical Enquiry

Current Behavior

I followed the steps here: https://github.com/alexa/alexa-skills-kit-sdk-for-python/tree/master/ask-smapi-sdk, in setting up the security profile, client ID, client secret and refresh token. I tried running the code, however, I faced the error below. {'error_description': 'Not authorized for requested operation', 'error_type': 'unauthorized_client'}

I came across this issue: https://github.com/alexa/alexa-skills-kit-sdk-for-python/issues/130, and tried the same code (changing the client_id, client_secret, refresh_token and vendor_id variables) and the exact same manifest.json, however I faced the error code below. Exception raised by client. Error code: 400 {'error_description': 'Not authorized for requested operation', 'error_type': 'unauthorized_client'}

Context

I am trying to send string texts/messages to Alexa via Python, as I have done a dialect translation module that returns the text in string, and would like to send to Alexa to run the skills. I came across this: https://developer.amazon.com/en-US/docs/alexa/smapi/skill-messaging-api-reference.html which says that I can indeed do that. But trying to configure it and all, I was led to the smapi (skill management API), so now I am unsure if I am on the right track too. If anyone could advise, it would be greatly appreciated.

One additional question I have is if I am able to send the string text to Alexa just solely using python or do I have to use node.js/ other programming languages?

Your Environment

Python version info

nikhilym commented 4 years ago

Hi @dadarrel , skill messaging API doesn't need you to set up SMAPI. You can use the API directly from the service client created from scratch, if you are trying to send events to skills through an out-of-session process. You can check a code sample here.

Please let us know if you still face issues or have questions after following that.

dadarrel commented 4 years ago

Hi @nikhilym, thank you for your help. Following the code sample that you have linked, I am unable to find the reminder_id. I have done some search, but I still have no clue on how to go about retrieving it.

Really appreciate your help. 👍

nikhilym commented 4 years ago

Hey @dadarrel , the above mentioned sample code is for sending reminder_id information to the skill. As you can see in the documentation, message can be any object. So depending on your needs, you can send whatever information you want to send to your skill. Hope this helps @dadarrel .

dadarrel commented 4 years ago

Hey @nikhilym, thank you for your help. I think I am able to send the message as I did not receive any error anymore. Is there a documentation or something that I can refer to for the retrieval of messages and even play the audio of Alexa through Python?