How to use the ask-sdk-core.SkillBuilders function in ask-sdk-core

To help you get started, we’ve selected a few ask-sdk-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github javichur / alexa-skill-clean-code-template / lambda / custom / index.js View on Github external
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
github alexa / alexa-cookbook / feature-demos / skill-connections / provider-demo / lambda / custom / index.js View on Github external
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();
github alexa / skill-sample-nodejs-hello-world / code / index.js View on Github external
},
    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();
github alexa / alexa-cookbook / feature-demos / skill-demo-dynamic-location / lambda / custom / index.js View on Github external
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();
github KayLerch / moustask / example / skill-sample-nodejs-fact / _dist / mars_facts / lambda / custom / index.js View on Github external
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: {
github Xzya / alexa-typescript-starter / lambda / custom / index.ts View on Github external
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,
github nitzzzu / alexa-local-skills / skills / subsonic / index.js View on Github external
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();
github alexa / alexa-cookbook / feature-demos / skill-demo-device-location / lambda / custom / index.js View on Github external
},
  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();
github dabblelab / alexa-remote-api-skill-template / lambda / custom / index.js View on Github external
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();
github dabblelab / dabblelab-youtube-channel / 2018-tutorials / 2018-06-29-76-api-starter / examples / random-quote / lambda / custom / index.js View on Github external
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();