Skip to content

Instantly share code, notes, and snippets.

@radTuti
Last active February 21, 2018 18:33
Show Gist options
  • Save radTuti/5696449aca55f2a18662fdafb9eabdca to your computer and use it in GitHub Desktop.
Save radTuti/5696449aca55f2a18662fdafb9eabdca to your computer and use it in GitHub Desktop.
fb-messenger-es6 button examples
// URL button
const urlButton = new UrlButton('Take the Hat Quiz', 'http://m.me/petershats?ref=take_quiz');
// to disable sharing
urlButton.disableSharing();
// set fallback url
urlButton..setFallbackUrl('http://m.me/petershats?ref=take_quiz');
//NOTE: All the methods can be chained
// URL button with messenger extensions
cosnt urlButtonWithMessengerExtensions = new UrlButton('Test Ext Button', 'http://m.me/test_url').enableMessengerExtensions();
// Postback button
const postbackButton = new PostbackButton('Bookmark Item', 'DEVELOPER_DEFINED_PAYLOAD');
// Call button
const callButton = new CallButton('Speak to Human', '+15105551234');
// Share button
const shareButton = new ShareButton();
// Share button with share_cotents attributes
const shareButtonWithShareContents = new ShareButton().setContents(new GenericTemplate([
new GenericElement('I took Peter\'s \'Which Hat Are You?\' Quiz')
.setSubTitle('My result: Fez')
.setImageUrl('https//bot.peters-hats.com/img/hats/fez.jpg')
.setDefaultAction(new DefaultAction('http://m.me/petershats?ref=invited_by_24601'))
.addButton(new UrlButton('Take Quiz', 'http://m.me/petershats?ref=invited_by_24601'))
]));
// Login and Logout buttons
const loginButton = new LogInButton('https://www.example.com/authorize');
const logoutButton = new LogOutButton();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment