Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
LOC.t = require(`./strings/${lang}.js`); // eslint-disable-line import/no-dynamic-require
LOC.langSkill = lang;
return;
} catch (e) {
// console.log(`Error reading strings. lang: ${lang}`);
}
}
// default lang
LOC.langSkill = Settings.DEFAULT_LANGUAGE;
LOC.t = require(`./strings/${LOC.langSkill}.js`); // eslint-disable-line import/no-dynamic-require
},
};
const skillBuilder = Alexa.SkillBuilders.custom();
exports.handler = skillBuilder
.addRequestHandlers(
LaunchRequestHandler,
HelloWorldIntentHandler,
HelpIntentHandler,
CheckPermissionsIntentHandler,
SaveSessionIntentHandler,
LoadSessionIntentHandler,
SaveDynamoDBIntentHandler,
LoadDynamoDBIntentHandler,
ColorIntentHandler,
EventHandler, // taps en pantalla APL
CancelAndStopIntentHandler,
FallbackIntentHandler, // to Respond Gracefully to Unexpected Customer Requests
GlobalHandlers.SessionEndedRequestHandler,
UseApiRequestHandler, // API sample
const ErrorHandler = {
canHandle(handlerInput, error) {
// handle all type of exceptions
return true;
},
handle(handlerInput, error) {
console.log("==== ERROR ======");
console.log(`Error handled: ${error}`);
return handlerInput.responseBuilder
.speak('Sorry, error occurred')
.getResponse();
},
};
exports.handler = Alexa.SkillBuilders
.custom()
.addRequestHandlers(
PrintWebPageTaskHandler,
LaunchRequestHandler,
SessionEndedRequestHandler,
HelpIntentHandler,
CancelAndStopIntentHandler,
)
.addErrorHandlers(ErrorHandler)
.withCustomUserAgent('cookbook/connections-provider/v1')
.lambda();
},
handle(handlerInput, error) {
console.log(`~~~~ Error handled: ${error.stack}`);
const speakOutput = `Sorry, I had trouble doing what you asked. Please try again.`;
return handlerInput.responseBuilder
.speak(speakOutput)
.reprompt(speakOutput)
.getResponse();
}
};
// The SkillBuilder acts as the entry point for your skill, routing all request and response
// payloads to the handlers above. Make sure any new handlers or interceptors you've
// defined are included below. The order matters - they're processed top to bottom.
exports.handler = Alexa.SkillBuilders.custom()
.addRequestHandlers(
LaunchRequestHandler,
HelloWorldIntentHandler,
HelpIntentHandler,
CancelAndStopIntentHandler,
SessionEndedRequestHandler,
IntentReflectorHandler, // make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers
)
.addErrorHandlers(
ErrorHandler,
)
.lambda();
function fixHeadingForLocale(heading, locale){
//special replacement for es-*
if(locale.startsWith('es')){
heading = heading.replace('norteeste', 'noreste');
heading = heading.replace('norteoeste', 'noroeste');
heading = heading.replace('norte-noreste', 'nor-noreste');
heading = heading.replace('norte-noroeste', 'nor-noroeste');
}
return heading;
}
// This handler acts as the entry point for your skill, routing all request and response
// payloads to the handlers above. Make sure any new handlers or interceptors you've
// defined are included below. The order matters - they're processed top to bottom.
exports.handler = Alexa.SkillBuilders.custom()
.addRequestHandlers(
LaunchRequestHandler,
MyLocationIntentHandler,
HelpIntentHandler,
CancelAndStopIntentHandler,
SessionEndedRequestHandler)
.addErrorHandlers(
ErrorHandler)
.addRequestInterceptors(LocalisationRequestInterceptor)
.withCustomUserAgent('cookbook/dynamic-location/v1')
.lambda();
postProcess: 'sprintf',
sprintf: values,
});
if (Array.isArray(value)) {
return value[Math.floor(Math.random() * value.length)];
}
return value;
};
const attributes = handlerInput.attributesManager.getRequestAttributes();
attributes.t = function translate(...args) {
return localizationClient.localize(...args);
};
},
};
const skillBuilder = Alexa.SkillBuilders.custom();
exports.handler = skillBuilder
.addRequestHandlers(
GetNewFactHandler,
HelpHandler,
ExitHandler,
FallbackHandler,
SessionEndedRequestHandler,
)
.addRequestInterceptors(LocalizationInterceptor)
.addErrorHandlers(ErrorHandler)
.lambda();
// translations
const deData = {
translation: {
import * as Alexa from "ask-sdk-core";
import * as Intents from "./intents";
import * as Errors from "./errors";
import * as Interceptors from "./interceptors";
import * as HelloIntents from "./intents/hello";
export const handler = Alexa.SkillBuilders.custom()
.addRequestHandlers(
// Intents.Debug,
// Default intents
Intents.Launch,
Intents.Help,
Intents.Stop,
Intents.SessionEnded,
Intents.SystemExceptionEncountered,
Intents.Fallback,
// Hello intents
HelloIntents.HelloWorld
)
.addErrorHandlers(
Errors.Unknown,
return handlerInput.responseBuilder.getResponse();
}
};
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.").getResponse();
}
};
module.exports = Alexa.SkillBuilders.custom()
.addRequestHandlers(
LaunchRequestHandler,
SearchIntentHandler,
HelpIntentHandler,
AudioPlayerHandler,
PauseIntentHandler,
ResumeIntentHandler,
RepeatIntentHandler,
LoopOnIntentHandler,
LoopOffIntentHandler,
StopIntentHandler,
SessionEndedRequestHandler
)
.addErrorHandlers(ErrorHandler)
.withSkillId(config.SUBSONIC_SKILL_ID)
.create();
},
handle(handlerInput, error) {
if (error.statusCode === 403) {
return handlerInput.responseBuilder
.speak(messages.NOTIFY_MISSING_PERMISSIONS)
.withAskForPermissionsConsentCard(PERMISSIONS)
.getResponse();
}
return handlerInput.responseBuilder
.speak(messages.LOCATION_FAILURE)
.reprompt(messages.LOCATION_FAILURE)
.getResponse();
},
};
const skillBuilder = Alexa.SkillBuilders.custom();
exports.handler = skillBuilder
.addRequestHandlers(
LaunchRequest,
GetAddressIntent,
SessionEndedRequest,
HelpIntent,
CancelIntent,
StopIntent,
UnhandledIntent,
)
.addErrorHandlers(GetAddressError)
.withApiClient(new Alexa.DefaultApiClient())
.withCustomUserAgent('cookbook/device-location/v1')
.lambda();
const getRemoteData = function (url) {
return new Promise((resolve, reject) => {
const client = url.startsWith('https') ? require('https') : require('http');
const request = client.get(url, (response) => {
if (response.statusCode < 200 || response.statusCode > 299) {
reject(new Error('Failed with status code: ' + response.statusCode));
}
const body = [];
response.on('data', (chunk) => body.push(chunk));
response.on('end', () => resolve(body.join('')));
});
request.on('error', (err) => reject(err))
})
};
const skillBuilder = Alexa.SkillBuilders.custom();
exports.handler = skillBuilder
.addRequestHandlers(
GetRemoteDataHandler,
HelpIntentHandler,
CancelAndStopIntentHandler,
SessionEndedRequestHandler
)
.addErrorHandlers(ErrorHandler)
.lambda();
const getRemoteData = function (url) {
return new Promise((resolve, reject) => {
const client = url.startsWith('https') ? require('https') : require('http');
const request = client.get(url, (response) => {
if (response.statusCode < 200 || response.statusCode > 299) {
reject(new Error('Failed with status code: ' + response.statusCode));
}
const body = [];
response.on('data', (chunk) => body.push(chunk));
response.on('end', () => resolve(body.join('')));
});
request.on('error', (err) => reject(err))
})
};
const skillBuilder = Alexa.SkillBuilders.custom();
exports.handler = skillBuilder
.addRequestHandlers(
GetRemoteDataHandler,
HelpIntentHandler,
CancelAndStopIntentHandler,
SessionEndedRequestHandler
)
.addErrorHandlers(ErrorHandler)
.lambda();