Created
November 12, 2020 17:26
-
-
Save seejee/fcbd59e0f42521cff78008dc1e1b99be to your computer and use it in GitHub Desktop.
Actions examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {}; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @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