Alexa Geographic location - aws-lambda

I am trying to get geographic location in an Alexa skill.
I have enabled location services in the Alexa console and I have authorized the skill to send geographic location.
The message I receive is the following:
{
"context": {
"Extensions": {
"available": {}
},
"System": {
"application": {
"applicationId": "..."
},
"device": {
"supportedInterfaces": {},
"deviceId": "..."
},
"apiEndpoint": "https://api.eu.amazonalexa.com",
"user": {
"userId": "...",
"permissions": {
"scopes": {
"alexa::devices:all:geolocation:read": {
"status": "GRANTED"
}
},
"consentToken": "..."
}
},
"apiAccessToken": "...",
"unit": {
"unitId": "..."
}
}
},
"version": "1.0",
"session": {
"application": {
"applicationId": "..."
},
"user": {
"userId": "...",
"permissions": {
"scopes": {
"alexa::devices:all:geolocation:read": {
"status": "GRANTED"
}
},
"consentToken": "..."
}
},
"new": true,
"sessionId": "..."
},
"request": {
"requestId": "...",
"locale": "it-IT",
"intent": {
"name": "MyIntent",
"confirmationStatus": "NONE"
},
"type": "IntentRequest",
"timestamp": "2021-01-28T07:39:53Z"
}
}
As you may see, the geographic location is GRANTED but the Geolocation field described here is completely missing.

You're correct on geolocation not being available for most Echo devices. Stationary devices only provide the registered address, not geographic coordinates.
https://developer.amazon.com/en-US/docs/alexa/custom-skills/location-services-for-alexa-skills.html#device-address-as-compared-to-geo-coordinates
You can, however use a "geocoding" service to convert most addresses to coordinates. For example Google Maps has a geocoding API.

Related

Any idea how to do custom supportedCookingModes in Alexa discovery?

I'm trying to return a Discovery Response, but the supportedCookingModes only seems to accept standard values and only in the format of ["OFF","BAKE"], not Custom values as indicated by the documentation. Any idea on how to specify custom values?
{
"event": {
"header": {
"namespace": "Alexa.Discovery",
"name": "Discover.Response",
"payloadVersion": "3",
"messageId": "asdf"
},
"payload": {
"endpoints": [
{
"endpointId": "asdf",
"capabilities": [
{
"type": "AlexaInterface",
"interface": "Alexa.Cooking",
"version": "3",
"properties": {
"supported": [
{
"name": "cookingMode"
}
],
"proactivelyReported": true,
"retrievable": true,
"nonControllable": false
},
"configuration": {
"supportsRemoteStart": true,
"supportedCookingModes": [
{
"value": "OFF"
},
{
"value": "BAKE"
},
{
"value": "CUSTOM",
"customName": "FANCY_NANCY_MODE"
}
]
}
}
]
}
]
}
}
}
Custom cooking modes are brand specific. This functionality is not yet publicly available. I recommend you to choose one of the existing cooking modes:
https://developer.amazon.com/en-US/docs/alexa/device-apis/cooking-property-schemas.html#cooking-mode-values

ARM Template unable to set $connections

I have created an ARM template in Visual Studio project with connection to slack. When I connect to slack in Azure portal - everything is fine. My slack API connection is authorized and works. My problem is with deployment and setting $connections.
Here is my template
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
<template-params>
},
"variables": {
"slack": "[concat(parameters('appPrefix'), '-slack-', parameters('environment'))]"
},
"resources": [
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"location": "[resourceGroup().location]",
"name": "[variables('slack')]",
"properties": {
"api": {
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/slack')]"
},
"displayName": "Slack",
"parameterValues": {}
}
},
{
"name": "[parameters('logicAppName')]",
"type": "Microsoft.Logic/workflows",
"location": "[parameters('logicAppLocation')]",
"tags": {
"displayName": "LogicApp"
},
"apiVersion": "2016-06-01",
"properties": {
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Collecting_went_wrong": {
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['slack']['connectionId']"
}
},
"method": "post",
"path": "/chat.postMessage",
"queries": {
"channel": "<channel>",
"text": "<message>",
"username": "<user>"
}
},
"runAfter": {},
"type": "ApiConnection"
}
},
"parameters": {
"$connections": {
"type": "object",
"defaultValue": {
}
}
},
"triggers": {
<trigger>
}
},
"parameters": {
"$connections": {
"value": {
"slack": {
"id": "[resourceId('Microsoft.Web/connections', variables('slack'))]",
"connectionId": "[resourceId('Microsoft.Web/connections', variables('slack'))]",
"connectionName": "slack"
}
}
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/connections', variables('slack'))]"
]
}
],
"outputs": {}
}
The 'fun' part is validation of template during the deployment:
New-AzureRmResourceGroupDeployment : 17:08:51 - Resource Microsoft.Logic/workflows 'reporting-reminder-logic-app-dev'
failed with message '{
"error": {
"code": "ConnectionsParameterInvalid",
"message": "The provided API connection parameter 'slack' is missing the required property 'id'."
}
}'
I'm really confused here.
What I tried to deploy it as connection and added $connection parameter definition as well, deployment went through. Nevertheless, when I changed connection to $connections in template parameters, Azure portal throw at me the same validation error.
Any idea what am I doing wrong here?
Thanks
The issue was about different ID in resources -> Microsoft/Web.connections -> properties -> id and slack -> connection. Once this connection ids were the same, the validation passed.
So it's only confusing validation message.

Logic App deployment from Visual Studio 2017 fails

I have created a Logic App in Azure which works fine in Azure itself. So I first recreated the Logic App within VS2017 (with "Azure Logic Apps for Visual Studio" extension installed). The logic app contains a trigger to read from the Azure Servicebus and calls a custom logic app connector action. This custom connector calls a SOAP webservice via an Azure Data Gateway, which runs fine.
Now the issue is that when I try to deploy it from VS2017, it complains in the Output window. The message I get is:
New-AzureRmResourceGroupDeployment : 13:41:34 - Resource MICROSOFT.WEB/CONNECTIONS 'MyCustomConnector' failed with message '{"error": {"code": "ConnectionGatewayFailure","message": "Establishing connection with the service failed with code 'BadRequest'."}}'
My Logic App works great because I receive the SOAP request in my on-premise application.
What I have tried so far:
Checked my permissions, I am now owner of the resource groups (one where the Logic App and custom connector resides in, and one where the Gateway resides in)
Copied content in: "My resource group > Settings > Automation script > Json Template" and pasted it into Visual Studio
Run Visual Studio as Administrator
Added "-DeploymentDebugLogLevel All" to my Deploy-AzureResourceGroup.ps1 file, doesn't show me anything more useful.
Troubleshoot common Azure deployment errors which says for BadRequest: "You sent deployment values that do not match what is expected by Resource Manager. Check the inner status message for help with troubleshooting." I see no inner status message.
Checked Google for a useful answer
But up until now, without success. So hopefully some of you can help me.
Edit: Here's my ARM template, I renamed a few things, hopefully not too much.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"connections_servicebus_name": {
"defaultValue": "servicebus",
"type": "String"
},
"customApis_MyCustomConnector_name": {
"defaultValue": "My-Custom-Connector",
"type": "String"
},
"connections_MyCustomConnector_name": {
"defaultValue": "My-Custom-Connector",
"type": "String"
},
"workflows_MyLogicApp_name": {
"defaultValue": "My-LogicApp",
"type": "String"
},
"workflows_MyLogicApp_id": {
"defaultValue": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Logic/integrationAccounts/My-Integration-Account",
"type": "String"
}
},
"variables": {},
"resources": [
{
"comments": "Generalized from resource: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup-B/providers/Microsoft.Logic/workflows/My-LogicApp'.",
"type": "Microsoft.Logic/workflows",
"name": "[parameters('workflows_MyLogicApp_name')]",
"apiVersion": "2017-07-01",
"location": "westeurope",
"tags": {},
"scale": null,
"properties": {
"state": "Enabled",
"integrationAccount": {
"id": "[parameters('workflows_MyLogicApp_id')]"
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
},
"actions": {
},
"outputs": {}
},
"parameters": {
"$connections": {
"value": {
"My-Custom-Connector": {
"connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_MyCustomConnector_name'))]",
"connectionName": "My-Custom-Connector",
"id": "[resourceId('Microsoft.Web/customApis', parameters('customApis_MyCustomConnector_name'))]"
},
"servicebus": {
"connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_servicebus_name'))]",
"connectionName": "servicebus",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/locations/westeurope/managedApis/servicebus"
}
}
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/connections', parameters('connections_MyCustomConnector_name'))]",
"[resourceId('Microsoft.Web/customApis', parameters('customApis_MyCustomConnector_name'))]",
"[resourceId('Microsoft.Web/connections', parameters('connections_servicebus_name'))]"
]
},
{
"comments": "Generalized from resource: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup-B/providers/Microsoft.Web/connections/My-Custom-Connector'.",
"type": "Microsoft.Web/connections",
"name": "[parameters('connections_MyCustomConnector_name')]",
"apiVersion": "2016-06-01",
"location": "westeurope",
"scale": null,
"properties": {
"displayName": "LogicAppsCustomConnector-Connection",
"customParameterValues": {},
"api": {
"id": "[resourceId('Microsoft.Web/customApis', parameters('customApis_MyCustomConnector_name'))]"
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/customApis', parameters('customApis_MyCustomConnector_name'))]"
]
},
{
"comments": "Generalized from resource: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup-B/providers/Microsoft.Web/connections/servicebus'.",
"type": "Microsoft.Web/connections",
"name": "[parameters('connections_servicebus_name')]",
"apiVersion": "2016-06-01",
"location": "westeurope",
"scale": null,
"properties": {
"displayName": "worker_outbound",
"customParameterValues": {},
"api": {
"id": "[concat('/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/locations/westeurope/managedApis/', parameters('connections_servicebus_name'))]"
}
},
"dependsOn": []
},
{
"comments": "Generalized from resource: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup-B/providers/Microsoft.Web/customApis/My-Custom-Connector'.",
"type": "Microsoft.Web/customApis",
"name": "[parameters('customApis_MyCustomConnector_name')]",
"apiVersion": "2016-06-01",
"location": "westeurope",
"scale": null,
"properties": {
"connectionParameters": {
"authType": {
"type": "string",
"allowedValues": [
{
"value": "none"
}
],
"uiDefinition": {
"displayName": "Authentication Type",
"description": "Authentication type to connect to your API",
"tooltip": "Authentication type to connect to your API",
"constraints": {
"tabIndex": 1,
"required": "true",
"allowedValues": [
{
"text": "none",
"value": "anonymous"
}
],
"capability": [
"gateway"
]
}
}
},
"gateway": {
"type": "gatewaySetting",
"gatewaySettings": {
"dataSourceType": "CustomConnector",
"connectionDetails": []
},
"uiDefinition": {
"constraints": {
"tabIndex": 4,
"required": "true",
"capability": [
"gateway"
]
}
}
}
},
"brandColor": "#ffffff",
"description": "Calls My SOAP test webservice.",
"displayName": "[parameters('customApis_MyCustomConnector_name')]",
"iconUri":
},
"dependsOn": []
}
]
}

Accessing collections data from Google+ API

I'm using the Google Plus API, and there seems to be no information in the JSON response regarding the collection of the post. I was wondering if there was a way to access which collection a post belongs using the API data.
For example, could we use the URL given to parse the collection from the webpage? Does anyone have any idea how this could be done in a performant way?
The google+ api is a read only api and every limited it gives you access to people, activities and comments.
Activites list returns a list of all activities#resource posts by a user. try it
The only collection you can send is public. the response looks like this.
{
"kind": "plus#activity",
"etag": "\"RKS4-q7QGL10FxltAebpjqjKQR0/82jivrLU7ubQ-fwlLaXGSt3krb8\"",
"title": "",
"published": "2018-06-18T07:03:54.034Z",
"updated": "2018-06-18T07:03:54.034Z",
"id": "z13lu3vowpa5x3aws04chl2brzavs1rplos0k",
"url": "https://plus.google.com/+LindaLawton/posts/STgianNMQwU",
"actor": {
"id": "117200475532672775346",
"displayName": "Linda Lawton",
"url": "https://plus.google.com/117200475532672775346",
"image": {
"url": "https://lh5.googleusercontent.com/-a1CWlFnA5xE/AAAAAAAAAAI/AAAAAAAAl1I/UcwPajZOuN4/photo.jpg?sz=50"
},
"verification": {
"adHocVerified": "UNKNOWN_VERIFICATION_STATUS"
}
},
"verb": "post",
"object": {
"objectType": "note",
"actor": {
"verification": {
"adHocVerified": "UNKNOWN_VERIFICATION_STATUS"
}
},
"content": "",
"url": "https://plus.google.com/+LindaLawton/posts/STgianNMQwU",
"replies": {
"totalItems": 0,
"selfLink": "https://content.googleapis.com/plus/v1/activities/z13lu3vowpa5x3aws04chl2brzavs1rplos0k/comments"
},
"plusoners": {
"totalItems": 0,
"selfLink": "https://content.googleapis.com/plus/v1/activities/z13lu3vowpa5x3aws04chl2brzavs1rplos0k/people/plusoners"
},
"resharers": {
"totalItems": 0,
"selfLink": "https://content.googleapis.com/plus/v1/activities/z13lu3vowpa5x3aws04chl2brzavs1rplos0k/people/resharers"
},
"attachments": [
{
"objectType": "article",
"displayName": "leastprivilege/AspNetCoreSecuritySamples",
"content": "AspNetCoreSecuritySamples - Samples for various ASP.NET Core Security Features",
"url": "https://github.com/leastprivilege/AspNetCoreSecuritySamples",
"image": {
"url": "https://lh3.googleusercontent.com/proxy/1pdxjC-TsuF0-8yHOZKvfDOXG1pNWAIemDoW7OzrFy8pcckGqr0BTJj-TwgW9KgEuoGLJjfUKLWSCouJwTT7FjoOmZ_xURQwzz4=w506-h910",
"type": "image/jpeg",
"height": 910,
"width": 506
},
"fullImage": {
"url": "https://avatars0.githubusercontent.com/u/1454075?s=400&v=4",
"type": "image/jpeg"
}
}
]
},
"provider": {
"title": "Google+"
},
"access": {
"kind": "plus#acl",
"description": "Public",
"items": [
{
"type": "public"
}
]
}
},
the above post here is actually within one of my collections. But no were in the response does it mention the id of the collection that its in which is olLcVE
As i mentioned this is a very limited api and what you want to do is not available.

Bot Framework doesn't have username if telegram profile doesn't have full name or username

Messages delivered from Bot Framework don't have name property in from object if message was sent by user who doesn't have username and full name. For example if you delete first or last name from profile like that
Here's example of json that I get for messages sent from user that only has first name (look at from object):
{
"channelData": {
"message": {
"chat": {
"all_members_are_administrators": true,
"id": -219911672,
"title": "jlarky-dev",
"type": "group"
},
"date": 1493246056,
"from": {
"first_name": "Test",
"id": 107390199
},
"message_id": 100,
"text": "test"
},
"update_id": 66470785
},
"channelId": "telegram",
"conversation": {
"id": "-219911672",
"isGroup": true,
"name": "jlarky-dev"
},
"entities": [
{
"mentioned": {
"id": "JLarkyTestBot",
"name": "jlarky_test"
},
"text": "JLarkyTestBot",
"type": "mention"
}
],
"from": {
"id": "107390199"
},
"id": "KxBlE8JsLfg",
"recipient": {
"id": "JLarkyTestBot",
"name": "jlarky_test"
},
"serviceUrl": "https://telegram.botframework.com",
"text": "test",
"timestamp": "2017-04-26T22:34:17.4109674Z",
"type": "message"
}
Since #NilsW's comment I tested this again and it looks like from.name only exists when username of telegram profile was set (same can be looked up from channelData.message.from.username), so I guess it makes sense for it not to show username when username was not set :) and not having last_name part was not related here.

Resources