Skip to content

Instantly share code, notes, and snippets.

View ankkal's full-sized avatar

Ankit Kala ankkal

  • Amazon
  • Bangalore
View GitHub Profile
try {
consentToken = this.event.context.System.user.permissions.consentToken;
deviceId = this.event.context.System.device.deviceId;
apiEndpoint = this.event.context.System.apiEndpoint;
if(!consentToken || !deviceId || !apiEndpoint) {
throw("User did not give us permissions to access their address.");
}
} catch(e) {
@ankkal
ankkal / PersistenceInterceptor.js
Created May 2, 2018 17:14
Request and Response Interceptors for Persistance in Node JS V2 SDK
const RequestPersistenceInterceptor = {
process(handlerInput) {
if(handlerInput.requestEnvelope.session['new']) {
return new Promise((resolve, reject) => {
handlerInput.attributesManager.getPersistentAttributes()
.then((sessionAttributes) => {
@ankkal
ankkal / DisplaySampleCodeV2.js
Last active December 23, 2020 03:14
V2 Display Code
// IMPORTANT: Display Interface for your skill should be enabled through the Amazon developer console
// See this screenshot - https://alexa.design/enabledisplay
/* HELPER FUNCTIONS */
// returns true if the skill is running on a device with a display (show|spot)
function supportsDisplay(handlerInput) {
var hasDisplay =
handlerInput.requestEnvelope.context &&
handlerInput.requestEnvelope.context.System &&
@ankkal
ankkal / index.js
Last active August 13, 2019 19:02
Display Directive and Video Directive Sample
/* eslint-disable func-names */
/* eslint-disable no-console */
// IMPORTANT: Please note that this template uses Dispay Directives,
// Display Interface for your skill should be enabled through the Amazon developer console
// See this screenshot - https://alexa.design/enabledisplay
const Alexa = require('ask-sdk');
const GetNewFactHandler = {
canHandle(handlerInput) {
//Place this inside the getnewfacthandler code inside the handler function
const request = handlerInput.requestEnvelope.request;
// SLOT: planet
if (request.intent.slots.planet &&
request.intent.slots.planet.value &&
request.intent.slots.planet.value !== '?'
) {
const planet = request.intent.slots.planet;
@ankkal
ankkal / BodyTemplate1.json
Created June 26, 2018 10:56
BodyTemplate1.json
{
"body": {
"version": "1.0",
"response": {
"outputSpeech": {
"type": "SSML",
"ssml": "<speak>hello and welcome to game skill ! Say help to hear some options.</speak>"
},
"card": {
"type": "Standard",
if (handlerInput.requestEnvelope.context.System.user.accessToken === undefined) {
return handlerInput.responseBuilder
.speak("to start using this skill, please use the companion app to authenticate")
.reprompt("to start using this skill, please use the companion app to authenticate")
.withLinkAccountCard()
.getResponse();
}
//Add this code inside your Intent Handler
if (handlerInput.requestEnvelope.context.System.user.accessToken !== undefined) {
accessToken = handlerInput.requestEnvelope.context.System.user.accessToken;
try {
var tokenOptions = buildHttpGetOptions(accessToken);
var response = await httpGet(tokenOptions);
console.log({ response });
Field Description
Do you allow users to create an account or link to an existing account with you? Select
Field Description
Do you allow users to create an account or link to an existing account with you? Select