Skip to content

Instantly share code, notes, and snippets.

Avatar

John Kelvie jkelvie

View GitHub Profile
@jkelvie
jkelvie / index.js
Last active Mar 26, 2018
Playing Audio With The AudioPlayer
View index.js
/**
* 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 Mar 1, 2017
Properly Injected SSML
View ExampleInjection.java
/**
* 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();
View CloudFunction-SecretKey
exports.simpleFunction = bst.Logless.capture("<YOUR_SECRET_KEY>", simpleFunction);
View CloudFunctionForFirebase
exports.simpleFunction = functions.https.onRequest(bst.Logless.capture("<YOUR_SECRET_KEY>", simpleFunction));
@jkelvie
jkelvie / SimpleTest.js
Last active Sep 29, 2017
A Simple Test Using Virtual Alexa
View SimpleTest.js
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 Sep 29, 2017
How VirtualAlexa Gets Configured
View VirtualAlexaConfigure.js
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();
View VirtualAlexa-CompleteGiftionaryTest
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) => {
View BSTProxy-VSCode-Configuration
{
"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}"
View GuessThePriceUnitTest
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 Nov 9, 2017
Simple Jovo Reply
View SimpleJovoReply
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);