Skip to content

Instantly share code, notes, and snippets.

View myke11j's full-sized avatar

Mukul Jain myke11j

View GitHub Profile
@myke11j
myke11j / alexa-skills-oauth-readme.md
Last active May 23, 2021 06:21
Alexa Skills OAuth
  1. Create a client app in congnito identity pool for Alexa
  2. Click on create secret key while creating app
  3. Check “Enable sign-in API for server-based authentication (ADMIN_NO_SRP_AUTH)”
  4. Go to “Client apps settings” and check “Cognito User Pool”
  5. In “Callback URL”field, add “https://alexa.amazon.co.jp/spa/skill/account-linking-status.html?vendorId=M1Q4KJDIT6UMXS”
  6. In “Allowed OAuth Flows “, check “Auth code grant”
  7. Check all 5 below scopes
  8. Share the
    1. Cognito Domain
  9. Alexa Client app’s client id and secret id
@myke11j
myke11j / alexa-account-linking-lambda-function
Created December 6, 2018 12:14
Lambda Function for Alexa Skill for Account Link card
const Alexa = require('alexa-sdk');
const APP_ID = process.env.ALEXA_ID;
const messages = {
greeting: 'Welcome to Dummy Skill',
goodByMsg: 'Goodbye',
reprompt: 'Sorry, I wasn\'t able to hear that, can you please repeat it?',
help: 'This is a dummy skill for showcasing Account Linking'
@myke11j
myke11j / alexa-account-linking-intent-schema
Last active December 6, 2018 12:12
Alexa user Account Linking using AWS Cognito - Alexa Skill intent schema
{
"interactionModel": {
"languageModel": {
"invocationName": "dummy skill",
"intents": [
{
"name": "AMAZON.FallbackIntent",
"samples": []
},
{
@myke11j
myke11j / .env
Created July 18, 2018 08:57
Alexa skills with Alexa SDK using Node.js
AWS_ENVIRONMENT=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_ROLE_ARN=
AWS_REGION=
AWS_FUNCTION_NAME=skill-name
AWS_HANDLER=index.handler
AWS_MEMORY_SIZE=128
AWS_TIMEOUT=10
AWS_DESCRIPTION=

Instructions

Simple running above file via node will show the name of organisation with address and rounded distance from Centre London in KMs.

node findNearestOffices.js

By deafult, it fetches offices within 100km of Centre London, but it is configurable. For eg, to find offices within 500km of Centre London, pass it as env variable like,

const deepClone = (params) => {
const { dataToClone } = params;
if (typeof dataToClone !== 'object') throw new Error('dataToClone must be of Object type')
return Object.assign({}, dataToClone);
};
const clonedData = deepClone({
dataToClone: {
name: { first: 'Mukul', last: 'Jain' },
location: 'New Delhi',
@myke11j
myke11j / s3.js
Last active December 19, 2020 12:56
const fs = require('fs');
const AWS = require('aws-sdk');
const s3 = new AWS.S3({
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
});
const fileName = 'contacts.csv';