Skip to content

Instantly share code, notes, and snippets.

@seejee
Created November 12, 2020 17:26
Show Gist options
  • Save seejee/fcbd59e0f42521cff78008dc1e1b99be to your computer and use it in GitHub Desktop.
Save seejee/fcbd59e0f42521cff78008dc1e1b99be to your computer and use it in GitHub Desktop.
Actions examples
const axios = require('axios');
/** @type {PostLoginAction} */
module.exports = async (event, context) => {
if(!event.user.userMetadata.catFact) {
const response = await axios.get('https://cat-fact.herokuapp.com/facts/random');
console.log("HI!")
return {
user: {
userMetadata: {
catFact: response.data.text
}
}
};
}
return {};
};
/** @type {PostLoginAction} */
module.exports = async (event, context) => {
if (event.protocol === 'redirect-callback') {
return {
user: {
appMetadata: {
actions: 'got-callback'
},
userMetadata: {
favoriteColor: event.actor.query.color
}
}
};
}
if (event.user.appMetadata.actions !== 'got-callback') {
return {
command: {
type: 'redirect',
url: 'https://actions-api-prompts-poc.herokuapp.com/my-custom-prompt'
}
};
}
return {};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment