Skip to content

Instantly share code, notes, and snippets.

@jirawatee
Last active May 27, 2019 19:44
Show Gist options
  • Save jirawatee/9c0d29a1f73c259d94f8281038bd40dd to your computer and use it in GitHub Desktop.
Save jirawatee/9c0d29a1f73c259d94f8281038bd40dd to your computer and use it in GitHub Desktop.
Structure of UCL Webhook API by Cloud Functions for Firebase
exports.UCL = functions.region(region).runWith(runtimeOpts)
.https.onRequest(async (req, res) => {
let event = req.body.events[0]
switch (event.type) {
case 'message':
if (event.message.type === 'image') {
// [8.3]
} else if (event.message.type === 'text' && event.message.text === 'subscribe') {
// [8.2]
} else {
// [8.1]
}
break;
case 'postback': {
// [8.4]
break;
}
}
return null;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment