Alexa: The requested skill did not provide a valid response on LauchRequest - alexa-skills-kit

I have started Alexa development very recently. Today I have suddenly started getting
which I did not encounter before.
The lambda function (index.js):
"use strict";
const Alexa = require("ask-sdk-core");
const http = require("http");
exports.handler = async (event, context, callback) => {
try {
if (event.request.type === "LaunchRequest") {
var welcomeMessage = '<speak>Hi</speak>';
callback(null, buildResponse(welcomeMessage, false));
}
else if (event.request.type === "AMAZON.CancelIntent") {
var msg2 = "<speak>Stopped!</speak>";
callback(null, buildResponse(msg2, true));
}
} catch (e) {
context.fail("Exception: ${e}");
}
};
function buildResponse(response, shouldEndSession) {
return {
version: "1.0",
response: {
outputSpeech: {
type: "SSML",
ssml: response
},
shouldEndSession: shouldEndSession
},
sessionAttributes: {}
};
}
package.json file:
{
"name": "third-test-skill",
"version": "1.0.0",
"description": "...",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Subrata Sarkar",
"license": "ISC",
"dependencies": {
"ask-sdk-core": "^2.5.2",
"ask-sdk-model": "^1.15.1"
}
}
Steps I followed to create the skill:
Crated a skill from AWS Alexa console
Created skill
Added sample utterances
Selected Lamda as end point Created a function called movieFacts
Uploaded .zip file containing the following file structure.
node_modules
|- ask-sdk-core
|- ask-sdk-model
|- ask-sdk-runtime
index.js
package.json
package.json.lock
When I say movie facts, I am getting the following message:
The requested skill did not provide a valid response
And this is the JSON output I am receiving:
{
"version": "1.0",
"session": {
"new": false,
"sessionId": "amzn1.echo-api.session.beca8832-50fe-4d17-96a4-30c855b18a4f",
"application": {
"applicationId": "amzn1.ask.skill.bdb88b1b-5a4a-4b37-9b63-71e78337bbca"
},
"user": {
"userId": "amzn1.ask.account.AEG2YALM6KQANVKR3YSUWKVN5DCKE66NJKN23SZIKRKZCVTU67E2JBZ5STPFIN325WNGGO5Z73FMVVL5X2SVEM27YEPD5VFNMPVDQSQK5XYW3NXOXSEIK6YPHE5HTZLGLCWW4VVQHLYECL6YBLG4XOTM2HTV5VCCQMPLVCIATFRSNS4DLHJFLY32JHD5N5MAPFBNRVN3YV7B53A"
}
},
"context": {
"System": {
"application": {
"applicationId": "amzn1.ask.skill.bdb88b1b-5a4a-4b37-9b63-71e78337bbca"
},
"user": {
"userId": "amzn1.ask.account.AEG2YALM6KQANVKR3YSUWKVN5DCKE66NJKN23SZIKRKZCVTU67E2JBZ5STPFIN325WNGGO5Z73FMVVL5X2SVEM27YEPD5VFNMPVDQSQK5XYW3NXOXSEIK6YPHE5HTZLGLCWW4VVQHLYECL6YBLG4XOTM2HTV5VCCQMPLVCIATFRSNS4DLHJFLY32JHD5N5MAPFBNRVN3YV7B53A"
},
"device": {
"deviceId": "amzn1.ask.device.AFXLD474IMHMD5V35NT2ZNUD5YLK2LTEJZUMO6DS2MY7ANONMZDZ67C3MU44OBJ6B5N4TPOXIJ64FBEFEOVOB2K4SSYEN3VTRSIHZETNTBNCDYUG6RGFIOKH7S7OBID6CG3WIHB774LNO4CFKWFUXYSNHD5HIAAXCEDKZ3U4EN7QB6EN4RRHQ",
"supportedInterfaces": {}
},
"apiEndpoint": "https://api.amazonalexa.com",
"apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b25hbGV4YS5jb20iLCJpc3MiOiJBbGV4YVNraWxsS2l0Iiwic3ViIjoiYW16bjEuYXNrLnNraWxsLmJkYjg4YjFiLTVhNGEtNGIzNy05YjYzLTcxZTc4MzM3YmJjYSIsImV4cCI6MTU1NzI0MTIxMCwiaWF0IjoxNTU3MjQwOTEwLCJuYmYiOjE1NTcyNDA5MTAsInByaXZhdGVDbGFpbXMiOnsiY29uc2VudFRva2VuIjpudWxsLCJkZXZpY2VJZCI6ImFtem4xLmFzay5kZXZpY2UuQUZYTEQ0NzRJTUhNRDVWMzVOVDJaTlVENVlMSzJMVEVKWlVNTzZEUzJNWTdBTk9OTVpEWjY3QzNNVTQ0T0JKNkI1TjRUUE9YSUo2NEZCRUZFT1ZPQjJLNFNTWUVOM1ZUUlNJSFpFVE5UQk5DRFlVRzZSR0ZJT0tIN1M3T0JJRDZDRzNXSUhCNzc0TE5PNENGS1dGVVhZU05IRDVISUFBWENFREtaM1U0RU43UUI2RU40UlJIUSIsInVzZXJJZCI6ImFtem4xLmFzay5hY2NvdW50LkFFRzJZQUxNNktRQU5WS1IzWVNVV0tWTjVEQ0tFNjZOSktOMjNTWklLUktaQ1ZUVTY3RTJKQlo1U1RQRklOMzI1V05HR081WjczRk1WVkw1WDJTVkVNMjdZRVBENVZGTk1QVkRRU1FLNVhZVzNOWE9YU0VJSzZZUEhFNUhUWkxHTENXVzRWVlFITFlFQ0w2WUJMRzRYT1RNMkhUVjVWQ0NRTVBMVkNJQVRGUlNOUzRETEhKRkxZMzJKSEQ1TjVNQVBGQk5SVk4zWVY3QjUzQSJ9fQ.UyCg4MXlOe16SlOyJnjAIiHzVpdLkRjd-izoKkUnGqiyZ0L_5eUpg8tKvVrCvTLNMtJS6ElksxgVfuLcNeOIwSbXtYCOXcSLRYbpcpgFI6oeamOZ2Yo-UMDEjzYi75fABuJyUJyZxp-Pieer8PMZO4G9-5zJXCVY2x3M_dmlpX23UBJDpW0DKddvAOzConmwgdaf3v_EWfc2q8BaCQIM950rEUbejOa08_AwE5CsqjNA9sD22QduE5hs09RV4-F-kU1zKvwwyDVDKyOkdFZQFEmCTC11_jI64re9c22e-hYR4leIE5XntNApMgtwaL-tHyjsJzVDVDfZd2q3w6wxYA"
},
"Viewport": {
"experiences": [
{
"arcMinuteWidth": 246,
"arcMinuteHeight": 144,
"canRotate": false,
"canResize": false
}
],
"shape": "RECTANGLE",
"pixelWidth": 1024,
"pixelHeight": 600,
"dpi": 160,
"currentPixelWidth": 1024,
"currentPixelHeight": 600,
"touch": [
"SINGLE"
],
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
}
}
},
"request": {
"type": "SessionEndedRequest",
"requestId": "amzn1.echo-api.request.c7b1b910-6309-48aa-af35-10ac0a20b5da",
"timestamp": "2019-05-07T14:55:10Z",
"locale": "en-US",
"reason": "ERROR",
"error": {
"type": "INVALID_RESPONSE",
"message": "An exception occurred while dispatching the request to the skill."
}
}
}

I think removing the <speak> and </speak> tags around the welcome message should do. They are by default generated by Alexa, so you don't need to provide them in your response.

What happened in my case (and definitely worth to check) is that I was using Serverless Framework to deploy Lambda and I changed the configuration in the serverless.yml but forgot to update the Lambda ARN in the Alexa Endpoint.
Updating the Endpoint to the correct ARN and rebuilding solved the issue.

Related

Make pwa from spa with workbox in offline mode and precahe all app

I make my pwa from spa so that the user can install and then use it offline,but my application does not work offline when I set offline mode in devTools and refresh the page,a standard browser page appears with a message that there is no network,how to cache the entire application using workbox and make it possible to use it even offline with the data that was received from the server online, and when the network appears, update the data.
Project on GitHub
//sw code
importScripts('https://storage.googleapis.com/workbox-cdn/releases/6.1.1/workbox-sw.js')
// Note: Ignore the error that Glitch raises about workbox being undefined.
workbox.setConfig({
debug: true,
})
const cacheName = workbox.core.cacheNames.precache
const setCacheName = workbox.core.setCacheNameDetails
setCacheName({
prefix: 'guest',
suffix: 'v1',
precache: 'precache',
runtime: 'run-time',
googleAnalytics: 'ga',
});
workbox.core.clientsClaim();
self.addEventListener('fetch', function (event) {
event.respondWith(
caches.match(event.request).then(function (response) {
return response || fetch(event.request);
}),
);
});
workbox.precaching.precacheAndRoute([{
"revision": "99dbb1ac10f49b8b1fcc4879f60b7313",
"url": "favicon.ico"
}, {
"revision": "31aed546ded10cc4f78ac847b857f18a",
"url": "index.html"
}, {
"revision": "6fd885036a48c65dc1c9476777ddfc83",
"url": "static/css/main.accd9ff3.css"
}, {
"revision": "c02707f96adb01d9981185c8d500653c",
"url": "static/js/main.42e89394.js"
}, {
"revision": "bc9520ea17b2e9685ba5961e7d87ed17",
"url": "manifest.json"
}, {
"revision": "b578821088f639079d5dd8764b0ca38e",
"url": "static/media/Calendar.10a98c21b62903a00d416f25939ddeae.svg"
}, {
"revision": "f8fe944931626bc821b23085075f0cc9",
"url": "static/media/email.cfd7fc9e9b6a564041920dd6a8418ed8.svg"
}, {
"revision": "fb91e587caa3bd4206dbce278d766110",
"url": "static/media/gift.6524bbfefbfc6ecc77b94cf52dd23d7d.svg"
}, {
"revision": "9d895d740e1ca4000cb70b3d657752e5",
"url": "static/media/logo.80e3b7f2aa8f0e234e644ab3f5e86b66.svg"
}, {
"revision": "65f28d384b705542ed8d0179b9fc40b7",
"url": "static/media/Phone.7f57311fdf0e51e1c3a76d81166f79c4.svg"
}, {
"revision": "dc62ffcc81ee5c0cea710c09027204fd",
"url": "static/media/profile.d8beab90a1c3af72e650dfbb71a80de6.svg"
}, {
"revision": "6d33824ebe9a9b702096ff730f0cbd6f",
"url": "static/media/qr.d90ce238c55f0df5833d9ed78d541502.svg"
}, {
"revision": "cf2ff7c1a111bf12ea0e0565bc450c5f",
"url": "static/media/user.6056b4037e72f4521dc8e1fefa10472d.svg"
}, {
"revision": "fdd15f825a6db43442a758e2db168314",
"url": "static/media/Geometria-Bold.3a9ed34be5c5b3d8fc3c.woff"
}, {
"revision": "45656b73e1a07f979bfb56559b359b07",
"url": "static/media/Geometria-Medium.ce81051a1ed94e89b4e1.woff"
}, {
"revision": "3c6a7d3ae76a5aec78aac69db1af15cf",
"url": "static/media/Geometria.b7f74b260291c82461d1.woff"
}, {
"revision": "cd42d299828c8762ff81eb5f1fe73dd2",
"url": "offline.html"
},
])
sw builder code
const {injectManifest} =require ('workbox-build')
let workboxConfig={
globDirectory:'../build',
globPatterns:[
'favicon.ico',
'index.html',
'static/css/*.*.css',
'static/js/*.*.js',
'asset-manifest.json',
'static/media/*.*.svg',
'static/media/*.*.woff',
'offline.html'
],
swSrc:'sw-workbox.js',
swDest:'../public/service-worker.js',
}
injectManifest(workboxConfig).then(({count,size})=>{
console.log(`Generate ${workboxConfig.swDest}, which will precache ${count} files, total ${size} bytes`)
})
sw for workbox
// Note: Ignore the error that Glitch raises about workbox being undefined.
workbox.setConfig({
debug: true,
})
const cacheName = workbox.core.cacheNames.precache
const setCacheName = workbox.core.setCacheNameDetails
setCacheName({
prefix: 'guest',
suffix: 'v1',
precache: 'precache',
runtime: 'run-time',
googleAnalytics: 'ga',
});
workbox.core.clientsClaim();
self.addEventListener('fetch', function (event) {
event.respondWith(
caches.match(event.request).then(function (response) {
return response || fetch(event.request);
}),
);
});
workbox.precaching.precacheAndRoute(self.__WB_MANIFEST)

How to generate mock server for pact consumer from contract json file?

I want to use contract file from provider to run tests against consumer.
I have
{
"provider": {
"name": "Provider"
},
"consumer": {
"name": "Consumer"
},
"interactions": [
{
"description": "Get data",
"request": {
"method": "Get",
"path": "/data/1"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"body": {
"message": ""
}
},
"providerState": "state"
}
],
"metadata": {
"pact-specification": {
"version": "2.0.0"
},
"pact-jvm": {
"version": "3.5.6"
}
}
And want to use it to generate pact mock server like:
RequestResponsePact pact = new RequestResponsePact(mockServerDescriptionString);
Is it possible to do this?
No. But you can use the pact-stub-server or the pact-stub-service CLI

I am not seeing dialogState in Alexa's event in AWS lambda logs, for a multiturn dialog?

I created an intent with slots in Alexa. This triggers an AWS lambda written in Python. I am logging the 'event'. I expect event['request']['dialogState'] to be present but it is not. Am I missing something?
Event:
{u'session': {u'application': {u'applicationId': u'amzn1.ask.skill.b2a191bb-7ee2-4fa7-aa7b-456d4bd2ee35'}, u'sessionId': u'Sessi onId.afb747ea-01ae-4094-ba10-ac49405a99df', u'user': {u'userId': u'amzn1.ask.account.BFHTSNCIVD2HA563BEPLRW5TSCESQEZXCIULPPB2ULOZBIJRCPM 5Z5NWOWH3HWNOZRTY4WT3FZFVGWWPKRSKC4ZNDSB2EYB45TYQ3RNY67CZPGF4GBMV6CL57C5MJVPIQPH25DQWGXGALDBCBRHMG5IA3Y26UHI7MHPIV3665ZU5OESS3UBADD7MDYQ BWJZFB3XHJS6IM2Y5UTQ', u'accessToken': None}, u'new': False, u'attributes': {}}, u'request': {u'locale': u'en-US', u'type': u'IntentRequ est', u'intent': {u'slots': {u'ncpu': {u'name': u'ncpu'}, u'nmem': {u'name': u'nmem'}}, u'name': u'CreateVM'}, u'requestId': u'EdwReques tId.c9de162a-d606-43a1-9257-b7367c9da5de', u'timestamp': u'2017-10-24T09:43:17Z'}, u'version': u'1.0', u'context': {u'AudioPlayer': {u'p layerActivity': u'IDLE'}, u'System': {u'device': {u'supportedInterfaces': {}}, u'application': {u'applicationId': u'amzn1.ask.skill.b2a1 91bb-7ee2-4fa7-aa7b-456d4bd2ee35'}, u'user': {u'userId': u'amzn1.ask.account.BFHTSNCIVD2HA563BEPLRW5TSCESQEZXCIULPPB2ULOZBIJRCPM5Z5NWOWH 3HWNOZRTY4WT3FZFVGWWPKRSKC4ZNDSB2EYB45TYQ3RNY67CZPGF4GBMV6CL57C5MJVPIQPH25DQWGXGALDBCBRHMG5IA3Y26UHI7MHPIV3665ZU5OESS3UBADD7MDYQBWJZFB3X HJS6IM2Y5UTQ'}}}}
You can not test you skills inside of the Amazon developer portal because these will not return a Dialogstate for your dialog. If you want to test your skill i suggest you go to echosim.io or get an echo dot to experiment with.
If you don't want to test with echosim.io or a real echo device and you have your skill code inside of AWS Lambda you can always test your code there with the test command.
Example:
{
"session": {
"new": true,
"sessionId": "SessionId.******************0ed735901",
"application": {
"applicationId": "amzn1.ask.skill.e96d9***********3ee1b958e6ca"
},
"attributes": {},
"user": {
"userId": "amzn1.ask.account.AGMQGVEZFE355BBMXYBQGFN7TRN5E5CSGUU5Y3AUNEBT3DOZ7IOQ3K7G3RGIOI7BEJVLVR4CWSARSTMAF5RNA4QW************DURTSESLYMYDVIQLWA2LF6PHG3KB3UEOLZWYBBWLRKCFFMG7JFP7TNKCS2RQ4KOGPIMOT2PGQT3S2HAOBNJSAA
}
},
"request": {
"type": "IntentRequest",
"dialogState": "IN_PROGRESS",
"requestId": "EdwRequestId.5b2a45f7-e4bb-44cd-ba9f-1cfe138d577f",
"intent": {
"name": "SearchIntent",
"slots": {
"AnswerTime": {
"name": "AnswerTime",
"value": "Nope"
},
"FirstTime": {
"name": "FirstTime",
"value": "02:00"
},
"SecondTime": {
"name": "SecondTime"
},
"Date": {
"name": "Date",
"value": "2017-10-20"
},
"Name": {
"name": "Name",
"value": "Liam De Lee"
}
}
},
"locale": "en-US",
"timestamp": "2017-10-19T13:29:17Z"
},
"context": {
"AudioPlayer": {
"playerActivity": "IDLE"
},
"System": {
"application": {
"applicationId": "amzn1.ask.skill.e96d95e0-8cbd-41d2-a280-3ee1b958e6ca"
},
"user": {
"userId": "amzn1.ask.account.AGMQGVEZFE355BBMXYBQGFN7TRN5E5CSGUU5Y3AUNEBT3DOZ7IOQ3K7G3RGIOI7BEJVLVR4CWSARSTMAF5RNA4QW************DURTSESLYMYDVIQLWA2LF6PHG3KB3UEOLZWYBBWLRKCFFMG7JFP7TNKCS2RQ4KOGPIMOT2PGQT3S2HAOBNJSAA"
},
"device": {
"supportedInterfaces": {}
}
}
},
"version": "1.0"
}
Note: Service Simulator does not currently support testing audio
player directives, dialog model, customer permissions and customer
account linking.
Amazon developer portal.

Using Pact.eachLike() when array contents vary for each item

Hi I have a Consumer test produced using Pact NPM https://www.npmjs.com/package/pact
I use the following code to generate a pact.json:
provider
.addInteraction({
state: 'test',
uponReceiving: 'a test,
withRequest: {
method: 'GET',
path: '/test'
},
willRespondWith: {
status: 200,
headers: { 'Content-Type': 'application/json' }
body: {
"company": like("My big company"),
"factories": eachLike({
"location": like("Sydney"),
"capacity": like(5)
},{min:1})
}
}
})
.then(function(){ done(); });
It generates the following testconsumer-testprovider.json file:
{
"consumer": {
"name": "TestConsumer"
},
"provider": {
"name": "TestProvider"
},
"interactions": [
{
"description": "a request for loans",
"providerState": "broker is logged in, list all loans",
"request": {
"method": "GET",
"path": "/test"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/vnd.hal+json"
},
"body": {
"company": "My big company",
"factories": [
{
"location": "Sydney",
"capacity": 5
}
]
},
"matchingRules": {
"$.headers.Content-Type": {
"match": "regex",
"regex": "application\\/.*json.*"
},
"$.body.company": {
"match": "type"
},
"$.body.factories": {
"min": 1
},
"$.body.factories[*].*": {
"match": "type"
},
"$.body.factories[*].location": {
"match": "type"
},
"$.body.factories[*].capacity": {
"match": "type"
}
}
}
}
],
"metadata": {
"pactSpecification": {
"version": "3.0.0"
}
}
}
However when we test against the following provided output we get an error with the geographicCoords because it's an unexpected key/value:
{
"company": "My Company",
"factories": [
{
"location": "Sydney",
"capacity": 5
},
{
"location": "Sydney",
"geographicCoords": "-0.145,1.4445",
"capacity": 5,
}
]
}
So is there a was to allow unexpected key/values in arrays because we're only test for required key/values and we don't want out pact tests to fail in future when new values are added to our providers.
The scenario you are describing is supported, see https://github.com/pact-foundation/pact-js/tree/master/examples/e2e for an example.
If you were to remove, say the eligibility object and run the tests everything still works.
If you are still having troubles, please raise a defect on the pact-js repository and we'll get to the bottom of it.

Google Analytics & Product Flavors

I used the answer provided here:
google-services.json for different productFlavors to add a google-services.json files to my app/src/dev flavor folder and one to my app/src/production flavor folder. My dev debug variant will generate Events in my dashboard but my production release variant does not. The tracking_id is correct so not sure what I am missing.
*I DO see a real Time Event for productionDebug variant, but why not productionRelease?
Also I have an res/xml/app_tracker.xml in each of my flavor folders
with each having its respective correct ga_trackingId
Here is my google-services-json file for my production flavor:
{
"project_info": {
"project_id": "shopper-64392",
"project_number": "475366498847",
"name": "Shopper"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:475366498847:android:847eba250b1fe1a7",
"client_id": "android:ts.kiosk.app.shoppers",
"client_type": 1,
"android_client_info": {
"package_name": "ts.kiosk.app.shoppers",
"certificate_hash": []
}
},
"oauth_client": [],
"api_key": [],
"services": {
"analytics_service": {
"status": 2,
"analytics_property": {
"tracking_id": "UA-76684740-1"
}
},
"cloud_messaging_service": {
"status": 1,
"apns_config": []
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"google_signin_service": {
"status": 1
},
"ads_service": {
"status": 1
}
}
}
],
"client_info": [],
"ARTIFACT_VERSION": "1"
}

Resources