Skip to content

Instantly share code, notes, and snippets.

View jkelvie's full-sized avatar

John Kelvie jkelvie

View GitHub Profile
@jkelvie
jkelvie / PokedexLaunchUnitTest
Last active November 9, 2017 17:27
Pokedex Launch Unit Test
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) => {
@jkelvie
jkelvie / SimpleJovoReply
Last active November 9, 2017 17:27
Simple Jovo Reply
const repromptMessage = 'Ask me which number of pokemon you want to know about';
const errorMessage = 'There was an error with your request, please try again';
const goodbyeMessage = 'Thank you for using my pokedex! Remember to catch them all!';
const pikachuAudio = 'https://s3.us-east-2.amazonaws.com/diego-bst-generalbucket/pikachu.mp3';
const handlers = {
'LAUNCH': function () {
var welcome = 'Welcome to my pokedex. ' + repromptMessage;
app.ask(welcome, repromptMessage);
@jkelvie
jkelvie / PokedexDescriptionState
Last active November 9, 2017 17:13
DescriptionState for the Pokedex Voice App
'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');
it("Launches successfully", async function() {
const bvd = require("virtual-alexa");
const alexa = bvd.VirtualAlexa.Builder()
.handler("index.handler") // Lambda function file and name
.intentSchemaFile("./speechAssets/IntentSchema.json")
.sampleUtterancesFile("./speechAssets/SampleUtterances.txt")
.create();
let reply = await alexa.launch();
assert.include(reply.response.outputSpeech.ssml, "Welcome to guess the price");
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Proxy",
"program": "${workspaceRoot}/node_modules/bespoken-tools/bin/bst-proxy.js",
"args": ["lambda", "src/index.js"],
"cwd": "${workspaceRoot}"
test("Plays once", (done) => {
alexa.utter("get started").then((payload) => {
expect(payload.response.outputSpeech.ssml).toContain("What is the search term for it");
return alexa.utter("incorrect guess");
}).then((payload) => {
expect(payload.response.outputSpeech.ssml).toContain("Nice try");
return alexa.utter("incorrect guess");
}).then((payload) => {
@jkelvie
jkelvie / VirtualAlexaConfigure.js
Created September 29, 2017 22:03
How VirtualAlexa Gets Configured
let alexa = virtualAlexa.VirtualAlexa.Builder()
.handler("src/index.handler") // Lambda function file and name
.intentSchemaFile("./speechAssets/IntentSchema.json") // Path to IntentSchema.json
.sampleUtterancesFile("./speechAssets/SampleUtterances.txt") // Path to SampleUtterances
.create();
@jkelvie
jkelvie / SimpleTest.js
Last active September 29, 2017 22:01
A Simple Test Using Virtual Alexa
test("Launches and plays", (done) => {
// Launch the skill
alexa.launch().then((payload) => {
// Test the correct text response comes back
expect(payload.response.outputSpeech.ssml).toContain("We show you images we got from Giphy");
// Once it launches, say Yes
return alexa.utter("yes");
}).then((payload) => {
exports.simpleFunction = functions.https.onRequest(bst.Logless.capture("<YOUR_SECRET_KEY>", simpleFunction));
exports.simpleFunction = bst.Logless.capture("<YOUR_SECRET_KEY>", simpleFunction);