Skip to content

Instantly share code, notes, and snippets.

View jkelvie's full-sized avatar

John Kelvie jkelvie

View GitHub Profile
@jkelvie
jkelvie / index.js
Last active March 26, 2018 12:58
Playing Audio With The AudioPlayer
/**
* Plays a particular track, from specific offset
* @param audioURL The URL to play
* @param offsetInMilliseconds The point from which to play - we set this to something other than zero when resuming
*/
SimplePlayer.prototype.play = function (audioURL, offsetInMilliseconds) {
var response = {
version: "1.0",
response: {
shouldEndSession: true,
@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 / 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);