Skip to content

Instantly share code, notes, and snippets.

Avatar

John Kelvie jkelvie

View GitHub Profile
@jkelvie
jkelvie / PokedexDescriptionState
Last active Nov 9, 2017
DescriptionState for the Pokedex Voice App
View PokedexDescriptionState
'DescriptionState': {
'YesIntent': function () {
var P = new Pokedex();
var number = app.getSessionAttribute('pokemonNo');
var img = app.getSessionAttribute('pokemonImg');
P.getPokemonSpeciesByName(number) // with Promise
.then(function (response) {
var dexEntry = response.flavor_text_entries.filter(function (entry) {
return (entry.language.name === 'en');
@jkelvie
jkelvie / PokedexLaunchUnitTest
Last active Nov 9, 2017
Pokedex Launch Unit Test
View PokedexLaunchUnitTest
test("Launches and asks for voltorb, then cancels ", (done) => {
alexa.launch().then((payload) => {
expect(payload.response.outputSpeech.ssml).toContain("Ask me which number of pokemon you want to know about");
return alexa.utter("100");
}).then((payload) => {
expect(payload.response.outputSpeech.ssml).toContain("voltorb");
return alexa.utter("no");
}).then((payload) => {
View ChangingStateJovo
app.followUpState('DescriptionState')
.showImageCard(response.name, description, response.sprites.front_default)
.ask(speech, reprompt);
View GuessThePrice-CI-UnitTesting
machine:
node:
version: 6.9.2
dependencies:
pre:
- npm install -g ask-cli
test:
override:
View GuessThePrice-CI-EndToEnd
it("Runs through game with two players", async () => {
const virtualDevice = new vds.VirtualDevice(process.env.VIRTUAL_DEVICE_TOKEN);
await virtualDevice.message("alexa exit");
let result = await virtualDevice.message("open guess the price");
assert.include(result.transcript, "welcome to guess the price how many persons are playing today");
result = await virtualDevice.message("two");
console.log("Result: " + result.transcript);
assert.include(result.transcript, "what is your name");
@jkelvie
jkelvie / skill-sample-nodejs-fact.test.yml
Last active Apr 6, 2018
YAML Test Spec for Skill Sample Node.js Fact
View skill-sample-nodejs-fact.test.yml
---
configuration:
locale: en-US
---
- Test: "Test launch request" # Optional info about the test
- LaunchRequest: # LaunchRequest is "reserved" - it is interpreted not as an utterance but as a LaunchRequest
- response.outputSpeech.ssml =~ "Here's your fact: *"
- response.card.title =~ "Space Facts"
- repsonse.card.content =~ "*"
View AlexaLoadTestSample.js
const virtualAlexa = require("virtual-alexa");
const expect = require("expect");
const TEST_COUNT = 100; // The number of tests to run in total
const TEST_CONCURRENCY = 20; // The number of test to run concurrently
const TEST_OFFSET = 10; // Milliseconds to offset starting each test
const TEST_START = Date.now(); // The start time for the tests as a whole
let concurrentCalls = TEST_CONCURRENCY;
let calls = 0;
View CakewalkCode
// This sample demonstrates handling intents from an Alexa skill using the Alexa Skills Kit SDK (v2).
// Please visit https://alexa.design/cookbook for additional examples on implementing slots, dialog management,
// session persistence, api calls, and more.
const Alexa = require('ask-sdk-core');
const persistenceAdapter = require('ask-sdk-s3-persistence-adapter');
const launchDocument = require('./documents/launchDocument.json');
const birthdayDocument = require("./documents/birthdayDocument.json");
const util = require('./util');
View CakewalkVideo.json
{
"streamURL": null,
"raw": {
"messageBody": {
"directives": [
{
"namespace": "SpeechRecognizer",
"payload": {},
"name": "StopCapture"
},
View Capabilities-API-JSON
{
"envelopeVersion": "20160207",
"capabilities": [
{
"type": "AlexaInterface",
"interface": "Alerts",
"version": "1.3"
},
{
"type": "AlexaInterface",