Comments (8)
Hi @MnHung - just saying alexa.utter("do some work") as a first call to the emulator should do it. Have you tried that? It is equivalent to saying "ask skill to do some work".
from virtual-alexa.
from virtual-alexa.
Thank you @jkelvie , yes it works.
um... should I close it or something? I am new to github
from virtual-alexa.
I am probably missing something simple, but I am unable to get my LaunchRequest
to trigger. I set up a very simple index.js
:
"use strict";
const Alexa = require("alexa-sdk");
//=============================================================================
const APP_ID = "amzn1.ask.skill.[unique-value-here]";
const HELP_MESSAGE = "You can ask for help.";
const HELP_REPROMPT = "Ask for help.";
const STOP_MESSAGE = "Goodbye!";
exports.handler = (event, context) => {
const alexa = Alexa.handler(event, context);
alexa.appId = APP_ID;
alexa.registerHandlers(handlers);
alexa.execute();
};
const handlers = {
"LaunchRequest" : function() {
console.log("DEBUG: start LaunchRequest");
this.attributes.speechOutput = "Welcome to the test program.";
this.response.speak(this.attributes.speechOutput);
this.emit(':responseReady');
},
"AMAZON.HelpIntent": function() {
this.attributes.speechOutput = HELP_MESSAGE;
this.attributes.repromptSpeech = HELP_REPROMPT;
this.response.speak(this.attributes.speechOutput)
.listen(this.attributes.repromptSpeech);
this.emit(":responseReady");
},
"AMAZON.RepeatIntent": function() {
this.response.speak(this.attributes.speechOutput)
.listen(this.attributes.repromptSpeech);
this.emit(":responseReady");
},
"AMAZON.CancelIntent": function() {
this.emit("EndSession");
},
"AMAZON.StopIntent": function() {
this.emit("EndSession");
},
"EndSession": function() {
this.response.speak(STOP_MESSAGE);
this.emit(":responseReady");
},
"Unhandled": function() {
this.attributes.speechOutput = "No intent match.";
this.attributes.repromptSpeech = "Try again";
this.response.speak(this.attributes.speechOutput)
.listen(this.attributes.repromptSpeech);
this.emit(":responseReady");
},
};
for testing using Jest with this test file:
const vax = require("virtual-alexa");
const alexa = vax.VirtualAlexa.Builder()
.handler("../src/index.handler") // Lambda function file and name
.interactionModelFile("./model.json")
.applicationID("amzn1.ask.skill.[unique-value-here]")
.create();
test("Launches successfully", (done) => {
alexa.utter("get started").then((payload) => {
expect(payload.response.outputSpeech.ssml).toContain("Welcome");
return alexa.utter("");
});
});
And it triggers the CancelIntent
instead of LaunchRequest
. Specifically:
console.warn node_modules/virtual-alexa/lib/src/SkillInteractor.js:33
No intentName matches utterance: get started. Using fallback utterance: cancel
What am I doing wrong? If you need the code, I put it up at https://github.com/ultradian/AlexaTesting
For package.json
I used:
{
"name": "unitTest",
"version": "1.0.0",
"private": true,
"dependencies": {
"alexa-sdk": "^1.0.22",
"i18next": "^10.2.1",
"i18next-sprintf-postprocessor": "^0.2.2"
},
"devDependencies": {
"jest": "^22.3.0",
"pack-zip": "^0.2.2",
"virtual-alexa": "^0.4.2"
},
"scripts": {
"build-aws-resource": "pack-zip",
"test": "jest"
}
}
from virtual-alexa.
Hi @ultradian - you want to call alexa.launch
instead of utter
to get a launch request. See here:
https://github.com/bespoken/giftionary/blob/master/test/index.test.js#L48
Let me know if that works for you! Best, John
from virtual-alexa.
Thanks, John. That works great. I didn't go deep enough into the code... Is there a doc page besides https://github.com/bespoken/virtual-alexa/blob/master/README.md? The info at http://docs.bespoken.io/ only describes bstAlexa.
from virtual-alexa.
Yes, take a look here:
https://bespoken.github.io/virtual-alexa/api/
from virtual-alexa.
Thanks for the link. I'll put it in the Github. A further question that I don't see documented (but probably is there somewhere)... is there a way to trigger the 'Unhandled' intent? I think there is some config file I'm missing because it says it is using a 'fallback utterance' which defaults to cancel
.
from virtual-alexa.
Related Issues (20)
- session is undefined when using filter with addRequestInterceptors HOT 2
- How to simulate a linked account? HOT 2
- Howto: use a locally hosted lambda HOT 2
- Do you interest to support Amazon Presentation Language? HOT 2
- Support DynamoDB.DeleteItem in DynamoDB.mock() HOT 1
- Testing AMAZON.FallbackIntent HOT 1
- request builder - confirm intent requires named dialog to exist
- Add mock for `getSystemTemperatureUnit` (`UpsServiceClient `)
- Dialog Manager- returns response with missing parameters HOT 3
- Unable to mock countryAndPostalCode call due to missing nock for Options call HOT 3
- Setting the Viewport in the context is not supported HOT 2
- Missing support for new built-in intent AMAZON.SelectIntent HOT 5
- Ensure additional elements do not appear in generated docs HOT 1
- Incorrect type interface for IResponse HOT 7
- Dialog slot confirmation, documentation needed HOT 6
- sdk.emit(":tell", ...) doesn't end the session HOT 3
- Alexa code in Google Cloud HOT 2
- AlexaSkill ID verification failed. HOT 2
- Throws an error as elicitSlot when the invoking intent is not associated
- Dialog Flow broken HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from virtual-alexa.