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

To help you get started, we’ve selected a few ask-sdk 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 alexa / alexa-cookbook / feature-demos / skill-demo-list-events / lambda / custom / index.js View on Github external
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();
github alexa / alexa-cookbook / feature-demos / skill-demo-list-access / lambda / custom / index.js View on Github external
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();
github internetarchive / internet-archive-voice-apps / functions / src / platform / alexa / handler / index.js View on Github external
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
github alexa / alexa-cookbook / feature-demos / skill-demo-progressive-response / lambda / custom / index.js View on Github external
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 =&gt; 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();
github freeCodeCamp / FreeCodeCampTriviaQuiz / index.js View on Github external
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();
github RocketChat / alexa-rocketchat / lambda / custom / index.js View on Github external
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,
github Xzya / alexa-lambda-typescript / src / hello / index.ts View on Github external
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();
github robm26 / travel-browser / lambda / custom / index.js View on Github external
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,
github robm26 / travel-browser / lambda / index / index.js View on Github external
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,
github alexa / alexa-cookbook / feature-demos / skill-demo-proactive-events / skill / lambda / custom / index.js View on Github external
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)

ask-sdk

Standard distribution package for Alexa Skills Kit SDK

Apache-2.0
Latest version published 1 year ago

Package Health Score

65 / 100
Full package analysis