Last active
January 14, 2022 19:21
-
-
Save Anshul0305/a3cc9e792fc58c8c07a8f7f5c878985f to your computer and use it in GitHub Desktop.
Facebook Code Snippets
This file contains 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
{ | |
"facebook":{ | |
"attachment": { | |
"type": "template", | |
"payload": { | |
"template_type":"open_graph", | |
"elements":[ | |
{ | |
"url":"https://gmail.com" | |
} | |
] | |
} | |
} | |
} | |
} |
This file contains 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
{ | |
"facebook": { | |
"attachment": { | |
"type": "template", | |
"payload": { | |
"template_type":"generic", | |
"elements":[ | |
{ | |
"title":"Here is your title!", | |
"image_url":"https://i.imgur.com/fFxXB2m.png", | |
"subtitle":"Here goes your subtitle.", | |
"default_action": { | |
"type": "web_url", | |
"url": "https://google.com", | |
"webview_height_ratio": "tall" | |
}, | |
"buttons":[ | |
{ | |
"type":"web_url", | |
"url":"https://facebook.com", | |
"title":"Link to Facebook" | |
},{ | |
"type":"postback", | |
"title":"Some Text", | |
"payload":"Some Text" | |
} | |
] | |
} | |
] | |
} | |
} | |
} | |
} |
This file contains 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 {Image} = require('dialogflow-fulfillment'); | |
// Simple text | |
const name = 'Anshul'; | |
agent.add(`Hello ${name}`); | |
// Sending images | |
agent.add(new Image('https://i.imgur.com/DYLlv4G.gif')); | |
// Sending quick replies | |
agent.add(`Would you like to understand how I may be of use to you? Please say Yes or No`); | |
agent.add(new Suggestion(`Yes`)); | |
agent.add(new Suggestion(`No`)); | |
// Sending cards | |
const card = new Card('Here is a Card Template'); | |
card.setImage('https://i.imgur.com/w6ubJcV.png'); | |
card.setText('Click on the below button '); | |
card.setButton({text: 'Go to Google.com', url: 'https://google.com'}); | |
agent.add(card); | |
// Setting contexts | |
agent.setContext({ name: 'context-name', lifespan: 2, parameters: { city: 'Rome' }}); | |
// Setting follow up event | |
agent.setFollowupEvent('SOME_EVENT'); |
This file contains 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
{ | |
"facebook": { | |
"text": "Here is a quick reply!", | |
"quick_replies":[ | |
{ | |
"content_type":"text", | |
"title":"How to get more out of your team or clients", | |
"payload":"How to get more out of your team or clients", | |
"image_url":"http://example.com/img/red.png" | |
}, | |
{ | |
"content_type":"location" | |
} | |
] | |
} | |
} |
This file contains 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
{ | |
"facebook":{ | |
"attachment": { | |
"type": "template", | |
"payload": { | |
"template_type": "media", | |
"elements": [ | |
{ | |
"media_type": "video", | |
"url": "https://www.facebook.com/AllTimeConspiracies/videos/199444947485193/" | |
} | |
] | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment