Invoke an Alexa Skill task from a web service - alexa

I am having a use case where we need to invoke a Alexa Skill directive/task from a webservice. We have all data like access token, deviceId, CustomerId, etc., in the caller webservice. I need to see whether there is a way we can invoke a custom skill from backend.
Thanks in Advance.

Related

Inject (own) Azure Ad id_token in Office Scripts external fetch request

Looking to make an Azure-AD authenticated external API call from within an Office-Scripts-enabled Excel Online workbook. Access to the workbook is secured to members of my organization only, so interaction with the workbook is possible only via an (Azure-AD) authenticated session.
Do you have any idea on the user's own id_token could be injected in the request? This way, the receiving end would be able to validate that the request originated from an authenticated user, by validating the token's signature.
Kind regards
There is no supported way to inject the user token into an Office Script right now. For authenticated calls, the recommended approach is to create a Power Automate Flow that uses the appropriate credentials to fetch whatever data the Office Script needs, then pass it to the script via its optional params in main, perform processing, and either write to the document or return the value from the script so the subsequent Flow steps can consume it. Does that work for your scenario?

Philips Hue Alexa Skill Authorization

I'm creating an Alexa Skill to control my Philips Hue lights. Everything works as expected, however the token expires after a couple of weeks and Alexa does not refresh the token. I am assuming this is because the Alexa skill setup only takes one URL which is supposed to be able to be used to both acquire a token and refresh a token, however the Hue API has two separate endpoints:
https://api.meethue.com/oauth2/token to get a token and https://api.meethue.com/oauth2/refresh to refresh.
Is there any way to get around this issue in the Alexa setup or with the Hue API?
I ended up writing a new lambda function which served as a reverse proxy to the Hue API. I would direct to the /token or /refresh endpoints based on the grant_type passed in the request body.
It would be nice if Hue resolved this discrepancy but this solution seems to work and I learned some things along the way 🎉
** If anyone needs the code for the above let me know. It's still in a private repo but I'm planning to open-source it soon.

How do I send Alexa smarthome proactive changeReports from a sensor?

I am using LWA as my oauth2 provider and need to send change reports when my contact sensors change state. Because of LWA account linking I've determined that I will have to store access and refresh tokens in a database from my skill. If that's the case, then the only way to send a report is to have my server send data to the skill which sends the actual directive to the endpoint. If that is the case, how do I create a separate trigger or function that will receive data from my server, repackage it and send to the endpoint?
And if the best way to do this is to have my server contact the endpoint directly, which seems more elegant to me, how would I get the necessary tokens or auth code to my server for storage?
When sending events to Alexa Event Gateway, there's no requirement on whether to send it through your skill Lambda v.s. your backend server. As long as you have the access token of the user, you can send the event from anywhere you want.
I think the easiest way to implement this is to have your skill stores the access and refresh token in DynamoDB. When the device state changes, your backend server would retrieve the access token from DynamoDB and then send the event to Alexa Event Gateway.

Twilio Programmable voice on Android/iOS - Passing custom information when making a call

Using the twilio mobile SDK on Android/iOS, to make a voice call to support operators at the backend (purely voip, no phone at either end. Support operators will be using a backend web app that uses the twilio api/twiml to receive and queue calls)
We have one very important requirement -- to be able to pass the user-id from the mobile app to the backend when placing the call. This is required for the backend web-app to be able to automatically pull up the user's information for the support operator who picks up the call in-browser.
Is this possible with the mobile SDK by any method? Any insight would be appreciated
Edit: Can I perhaps use this user-id as the callerid parameter when dialling, and have it read at the web-app side?
After a day of working with Twilio functions, I came up with the following solution.
Mobile app gets access token, hits the Twilio voice endpoint, is routed to the queue, wait music plays etc.
Operator (web app) gets access token, hits the Twilio voice endpoint, and automatically dequeues the first caller from the queue (i.e is connected to them)
In the TwiML for the operator dequeuing, there is a parameter url which is a TwiML URL that will be fetched and executed on the queued caller's end before the caller is connected to the operator. Twilio passes a bunch of parameters to this URL, including the caller identity and the operator's call sid
We will host this URL at our backend, and store a map of {caller identity, operator call sid}.
The operator web app will poll the backend once the operator dials, until the caller identity corresponding to the current operator call sid is returned. Or the backend can send some kind of push notification to the operator web app. This is up to the implementation (we will use websockets)
For more info please see https://www.twilio.com/docs/voice/twiml/queue
Edit - Twilio javascript API 1.5 supports access tokens instead of capability tokens, so it is simpler to use them for both mobile app and web app.
Edit 2 - Tested this flow today and works fine :-)

Angular injection loop

I am having a problem in my AngularJS and I cannot seem to find easy solution out of it.
I am using two services for user authorization with the server. The authorisation is based on two tokens: Access token and Refresh token.
Now I have one service (Auth) that takes care of the whole authorisation process and second service (Api) that takes care of communication with the server.
The way the authorisation works is that user accesses data with his Access Token. Once the token is invalitated, it will try to submit refresh token and hopefully get back new access token.
The problem is that if server responds with 401 and the token is invalidated I want to simply run Auth.authenticate(); on the background (no redirects or anything) and if successful continue with tthe new access token.
Unfortunately since Auth service is using Api service , I cannot inject Auth service back to the Api service. Is there any good way to do what I want to do from one global place(So I dont have to call the re-authorization after every single request in controller)?
Some architectural info:
Auth Service (injects Api Service)
| ---- authorisation function (uses Api Service)
Api Service
| ---- Different functions to prepare data for request
| ---- One function to send all requests
| ---- One function to handle all rejected promisses which includes detection of 401 and should include "silent" re-authorisation (AuthService.authorisation)
I really hope it doesnt sound too confusing.
I have tried interceptors, but the outcome is the same - injector loop.
The only idea I have, without changing my architecture, is if there is any way to get current active instance of the Auth service, as it is loaded anyway. But couldn't find any details on that.
Thank you!
I had a similar problem, also with my authorisation.
Sometimes re-architecting is the best solution, but I think in this case you have a good use-case for wanting the 'circular' access you are describing.
Try the following:
Inject $injector into your API service instead of your Auth service.
User $injector.get('AuthService') to get the instantiated Auth service.

Resources