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": "vertical", | |
"elements": [ | |
{ | |
"type": "image", | |
"url": "https://cdn.bgr.com/2016/08/iphone-8-concept.jpg?quality=98&strip=all", | |
"tooltip": "image tooltip" | |
}, | |
{ | |
"type": "text", |
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
"payload": { | |
"template_type":"generic", | |
"elements":[ | |
{ | |
"title":"<TITLE_TEXT>", | |
"image_url":"<IMAGE_URL_TO_DISPLAY>", | |
"subtitle":"<SUBTITLE_TEXT>", | |
"default_action": { | |
"type": "web_url", | |
"url": "<DEFAULT_URL_TO_OPEN>", |
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
'use strict'; | |
const readline = require('readline'); | |
const DELAY = 100; | |
function startLoader() { | |
readline.cursorTo(process.stdout, 0); | |
process.stdout.write('/'); | |
setTimeout(loaderStage1, DELAY); | |
} |
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
//Send the login button | |
botly.sendButtons({ | |
id: recipientId, | |
text: 'Please Login :)', | |
buttons: [botly.createAccountLinkButton(`https://${LOGIN_DOMAIN}/auth/facebook`)], | |
}); | |
//Listen on the account link event | |
botly.on('account_link', (sender, message, link) => { | |
//Continue conversation |
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
app.get('/auth/facebook', (req, res, next) => { | |
passport.authenticate('facebook', { | |
callbackURL: 'http://localhost:3000/auth/facebook/callback?' + | |
(req.query.redirect_uri ? '&redirect_uri=' + req.query.redirect_uri : '') + | |
(req.query.account_linking_token ? '&account_linking_token=' + req.query.account_linking_token : ''), | |
scope: ['public_profile', 'email', 'user_friends', 'user_likes'] | |
})(req, res, next); | |
}); | |
app.get('/auth/callback/facebook', (req, res, next) => { |
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
passport.use(new FacebookStrategy({ | |
clientID: FACEBOOK_APP_ID, | |
clientSecret: FACEBOOK_APP_SECRET, | |
callbackURL: "http://localhost:3000/auth/facebook/callback" | |
}, | |
function(accessToken, refreshToken, profile, cb) { | |
User.findOrCreate({ facebookId: profile.id }, function (err, user) { | |
return cb(err, user); | |
}); | |
} |
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 express = require("express"); | |
const Botly = require("botly"); | |
const botly = new Botly({ | |
accessToken: pageAccessToken, //page access token provided by facebook | |
verifyToken: verificationToken, //needed when using express - the verification token you provided when defining the webhook in facebook | |
webHookPath: yourWebHookPath, //defaults to "/", | |
notificationType: Botly.CONST.REGULAR //already the default (optional) | |
}); | |
botly.on("message", (senderId, message, data) => { |