Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handle(handlerInput, error) {
const request = handlerInput.requestEnvelope.request;
console.log(`Original Request was: ${JSON.stringify(request, null, 2)}`);
console.log(`Error handled: ${error}`);
return handlerInput.responseBuilder
.speak('Sorry, I had trouble doing what you asked. Please ask for it again.')
.reprompt('Sorry, I had trouble doing what you asked. Please ask for it again.')
.getResponse();
},
};
// exports
const skillBuilder = Alexa.SkillBuilders.custom();
exports.handler = skillBuilder
.addRequestHandlers(
AmazonCancelStopHandler,
AmazonHelpHandler,
LaunchRequestHandler,
SkillEventHandler,
ItemEventHandler,
ListEventHandler,
SessionEndedHandler,
UnhandledHandler,
)
.addErrorHandlers(ErrorHandler)
.withApiClient(new Alexa.DefaultApiClient())
.withCustomUserAgent('cookbook/list-events/v1')
.lambda();
return (listIsEmpty);
}
// get first item
const item = list.items[0];
const updateRequest = {
value: item.value,
status: listStatuses.COMPLETED,
version: item.version,
};
return listClient.updateListItem(listId, item.id, updateRequest);
}
// exports
const skillBuilder = Alexa.SkillBuilders.custom();
exports.handler = skillBuilder
.addRequestHandlers(
AmazonCancelStopHandler,
AmazonHelpHandler,
LaunchRequestHandler,
CompleteTopToDoHandler,
TopToDoHandler,
SessionEndedHandler,
)
.addErrorHandlers(ErrorHandler)
.withApiClient(new Alexa.DefaultApiClient())
.withCustomUserAgent('cookbook/list-access/v1')
.lambda();
module.exports = (actions) => {
// TODO: we don't need it for session attributes
// turn on once we will have persistent attributes
const region = process.env.AWS_REGION || 'us-west-1';
debug('set AWS region', region);
const dynamoDbPersistenceAdapter = new DynamoDbPersistenceAdapter({
createTable: true,
dynamoDBClient: new AWS.DynamoDB({ apiVersion: 'latest', region }),
tableName: process.env.DYNAMO_DB_SESSION_TABLE || 'InternetArchiveSessions',
});
const handlers = handlersBuilder(actions);
debug(`We can handle intents: ${handlers.map(({ intent }) => `"${intent}"`).join(', ')}`);
let lambda = Alexa.SkillBuilders.custom()
.addRequestHandlers(...handlers)
.addErrorHandlers(ErrorHandler)
.addRequestInterceptors(
() => pipeline.stage(pipeline.PROCESS_REQUEST)
)
.addRequestInterceptors(LogInterceptor)
.addResponseInterceptors(
() => pipeline.stage(pipeline.IDLE)
)
.withPersistenceAdapter(dynamoDbPersistenceAdapter)
.lambda();
// wrap all log services
if (process.env.DASHBOT_KEY) {
// for the moment doesn't work
for (let i = startIndex; i < Math.min(events.length, startIndex + PAGINATION_SIZE); i += 1) {
speechOutputContent += `<p>${events[i]}</p>`;
cardOutputContent += `${events[i]}\n`;
}
return {
speechOutputContent,
cardOutputContent,
};
}
function sleep(milliseconds) {
return new Promise(resolve => setTimeout(resolve, milliseconds));
}
// 4. Exports handler function and setup ===================================================
const skillBuilder = Alexa.SkillBuilders.custom();
exports.handler = skillBuilder
.addRequestHandlers(
LaunchRequestHandler,
AmazonCancelStopNoHandler,
AmazonHelpHandler,
InProgressGetFirstEventHandler,
GetFirstEventHandler,
AmazonYesHandler,
SessionEndedHandler,
)
.addErrorHandlers(ErrorHandler)
.withApiClient(new Alexa.DefaultApiClient())
.withCustomUserAgent('cookbook/progressive-response/v1')
.lambda();
const ErrorHandler = {
canHandle() {
return true;
},
handle(handlerInput, error) {
console.log(`Error handled: ${error.message}`);
return handlerInput.responseBuilder
.speak('Sorry, I can\'t understand the command. Please say again. Or try saying Help, for a list of commands.')
.reprompt('Sorry, I can\'t understand the command. Please say again. Or try saying Help, for a list of commands.')
.getResponse();
},
};
const skillBuilder = Alexa.SkillBuilders.standard();
exports.handler = skillBuilder
.addRequestHandlers(
LaunchRequest,
HelpIntent,
AnswerIntent,
RepeatIntent,
YesIntent,
StopIntent,
CancelIntent,
NoIntent,
SessionEndedRequest,
UnhandledIntent
)
.addRequestInterceptors(LocalizationInterceptor)
.addErrorHandlers(ErrorHandler)
.lambda();
const ErrorHandler = {
canHandle() {
return true;
},
handle(handlerInput, error) {
console.log(`Error handled: ${ error.message }`);
const speechText = ri('ERRORS');
return handlerInput.jrb
.speak(speechText)
.reprompt(speechText)
.getResponse();
},
};
const skillBuilder = new Jargon.JargonSkillBuilder().installOnto(Alexa.SkillBuilders.standard());
exports.handler = skillBuilder
.addRequestHandlers(
ProactiveEventHandler,
LaunchRequestHandler,
ChangeNotificationSettingsIntentHandler,
StartedCreateChannelIntentHandler,
InProgressCreateChannelIntentHandler,
DeniedCreateChannelIntentHandler,
CreateChannelIntentHandler,
StartedDeleteChannelIntentHandler,
InProgressDeleteChannelIntentHandler,
DeniedDeleteChannelIntentHandler,
DeleteChannelIntentHandler,
StartedPostMessageIntentHandler,
InProgressPostMessageIntentHandler,
const ErrorHandler: Alexa.ErrorHandler = {
canHandle() {
return true;
},
handle(handlerInput, error) {
console.log(`Error handled: ${error.message}`);
return handlerInput.responseBuilder
.speak('Sorry, I can\'t understand the command. Please say again.')
.reprompt('Sorry, I can\'t understand the command. Please say again.')
.getResponse();
},
};
export const handler = Alexa.SkillBuilders.custom()
.addRequestHandlers(
LaunchRequestHandler,
HelloWorldIntentHandler,
HelpIntentHandler,
CancelAndStopIntentHandler,
SessionEndedRequestHandler,
)
.addErrorHandlers(ErrorHandler)
.lambda();
line = line.substring(0, line.indexOf(':'));
let speechOutput = 'Sorry, an error occurred. ';
if(debug) {
speechOutput += error.message + ' in ' + file + ', line ' + line;
}
return handlerInput.responseBuilder
.speak(speechOutput)
.reprompt(speechOutput)
.getResponse();
},
};
const skillBuilder = Alexa.SkillBuilders.standard();
exports.handler = skillBuilder
.addRequestHandlers(
ElementSelectedHandler,
BrowseCitiesHandler,
ShowCityHandler,
LinkSessionHandler,
MyNameIsHandler,
MyNameIsYesNoHandler,
LaunchHandler,
MyPhoneNumberHandler,
SpeakSpeedHandler,
ResetHandler,
line = line.substring(0, line.indexOf(':'));
let speechOutput = 'Sorry, an error occurred. ';
if(debug) {
speechOutput += error.message + ' in ' + file + ', line ' + line;
}
return handlerInput.responseBuilder
.speak(speechOutput)
.reprompt(speechOutput)
.getResponse();
},
};
const skillBuilder = Alexa.SkillBuilders.standard();
exports.handler = skillBuilder
.addRequestHandlers(
ElementSelectedHandler,
BrowseCitiesHandler,
ShowCityHandler,
LinkSessionHandler,
MyNameIsHandler,
MyNameIsYesNoHandler,
LaunchHandler,
MyPhoneNumberHandler,
SpeakSpeedHandler,
ResetHandler,
if(debug) {
speechOutput += error.message + ' in ' + file + ', line ' + line;
}
return handlerInput.responseBuilder
.speak(speechOutput)
.reprompt(speechOutput)
.withShouldEndSession(true)
.getResponse();
},
};
const skillBuilder = Alexa.SkillBuilders.standard();
exports.handler = skillBuilder
.addRequestHandlers(
NextGameHandler,
HelloWorldIntentHandler,
HelpIntentHandler,
CancelAndStopIntentHandler,
SessionEndedRequestHandler
)
.addErrorHandlers(ErrorHandler)
.addRequestInterceptors(interceptors.RequestPersistenceInterceptor)
.addRequestInterceptors(interceptors.RequestHistoryInterceptor)
.addResponseInterceptors(interceptors.ResponsePersistenceInterceptor)
.withTableName(DYNAMODB_TABLE)