Skip to content

Instantly share code, notes, and snippets.

View jkelvie's full-sized avatar

John Kelvie jkelvie

View GitHub Profile
@jkelvie
jkelvie / ExampleInjection.java
Last active March 1, 2017 15:50
Properly Injected SSML
/**
* Creates a {@code SpeechletResponse} for the hello intent.
*
* @return SpeechletResponse spoken and visual response for the given intent
*/
private SpeechletResponse getHelloResponse(Session session) {
String speechText = "Hello world";
// Create the Simple card content.
SimpleCard card = new SimpleCard();
exports.simpleFunction = bst.Logless.capture("<YOUR_SECRET_KEY>", simpleFunction);
exports.simpleFunction = functions.https.onRequest(bst.Logless.capture("<YOUR_SECRET_KEY>", simpleFunction));
@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) => {
@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();
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) => {
{
"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}"
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");
@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');
@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);