Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// This is only initialized when the Lambda is, so it is preserved across calls
// It is NOT a real database, but can be used for testing, as JavaScript Lambdas tend to live for a few hours
// Stay tuned for a more sophisticated example that uses DynamoDB
var lastPlayedByUser = {};
var podcastURL = "https://feeds.soundcloud.com/stream/309340878-user-652822799-episode-010-building-an-alexa-skill-with-flask-ask-with-john-wheeler.mp3";
const bst = require("bespoken-tools");
bst.Logless.Domain = "logless-dev.bespoken.tools";
// Entry-point for the Lambda
exports.handler = bst.Logless.capture("a756512f-d091-477a-a4f9-fd57c916787a", function(event, context) {
var player = new SimplePlayer(event, context);
player.handle();
});
// The SimplePlayer has helpful routines for interacting with Alexa, within minimal overhead
var SimplePlayer = function (event, context) {
this.event = event;
this.context = context;
};
// Handles an incoming Alexa request
SimplePlayer.prototype.handle = function () {
var requestType = this.event.request.type;
var userId = this.event.context ? this.event.context.System.user.userId : this.event.session.user.userId;
// On launch, we tell the user what they can do (Play audio :-))
.withPersistenceAdapter(dynamoDbPersistenceAdapter)
.lambda();
// wrap all log services
if (process.env.DASHBOT_KEY) {
// for the moment doesn't work
// because of https://github.com/actionably/dashbot/issues/28
lambda = dashbot(process.env.DASHBOT_KEY).alexa.handler(lambda);
} else {
warning('env variable DASHBOT_KEY should be defined to send logs to dashbot');
}
if (process.env.BESPOKEN_KEY) {
// FIXME: bespoken doesn't support ANSI color escape codes yet
lambda = bst.Logless.capture(process.env.BESPOKEN_KEY, lambda);
} else {
warning('env variable BESPOKEN_KEY should be defined to send logs to bespoken');
}
return lambda;
};
error('error on global error handler', err);
if (conv.raven) {
conv.raven.captureException(err);
}
}
}
// last chance to give response to user
if (!globalErrorWasHandled) {
conv.ask('Can you rephrase it?');
}
await after.handle(conv);
});
if (_.has(functions.config(), ['bespoken', 'key'])) {
return functions.https.onRequest(bst.Logless.capture(functions.config().bespoken.key, app));
} else {
warning('bespoken key missing\n');
return functions.https.onRequest(app);
}
};
// This is only initialized when the Lambda is, so it is preserved across calls
// It is NOT a real database, but can be used for testing, as JavaScript Lambdas tend to live for a few hours
// Stay tuned for a more sophisticated example that uses DynamoDB
var lastPlayedByUser = {};
var podcastURL = "https://feeds.soundcloud.com/stream/309340878-user-652822799-episode-010-building-an-alexa-skill-with-flask-ask-with-john-wheeler.mp3";
const bst = require("bespoken-tools");
bst.Logless.Domain = "logless-dev.bespoken.tools";
// Entry-point for the Lambda
exports.handler = bst.Logless.capture("a756512f-d091-477a-a4f9-fd57c916787a", function(event, context) {
var player = new SimplePlayer(event, context);
player.handle();
});
// The SimplePlayer has helpful routines for interacting with Alexa, within minimal overhead
var SimplePlayer = function (event, context) {
this.event = event;
this.context = context;
};
// Handles an incoming Alexa request
SimplePlayer.prototype.handle = function () {
var requestType = this.event.request.type;
},
'AMAZON.CancelIntent': function() {
emitResponse(this, `Goodbye`);
},
'AMAZON.StopIntent': function() {
emitResponse(this, `Goodbye`);
} /*,
Unhandled: function() {
var speechOutput = 'Sorry, something went wrong.';
var reprompt = 'Would you like to try again?';
this.response.speak(speechOutput + ' ' + reprompt).listen(reprompt);
this.emit(':responseReady');
}*/
};
exports.handler = bst.Logless.capture(
'ccc51960-fc8e-4cf3-b117-67bf2b90f105',
function(event, context) {
const APP_ID = 'amzn1.ask.skill.925e2d0a-2bd9-434a-83ae-c6bb8fd16085';
const alexa = Alexa.handler(event, context);
alexa.appId = APP_ID;
alexa.dynamoDBTableName = 'particleDeviceState';
alexa.registerHandlers(handlers);
alexa.execute();
}
);