- User Profile API
- Referral, optin and postback handling
- Quick Replies
- (Application) Insights
- Account Linking
- Sticker / Like Recognizer
- Microsoft BotBuilder (NodeJS)
Install the package through NPM.
npm install botbuilder-facebookextension --save. Choose which part of this package you would like to implement in your code.
User Profile API
In order to populate the userdata with the Facebook userdata, you can use a middleware. It will automatically retrieve the data from Facebook and store it before your first reply. By default it will refresh the userdata every day, but you can change it by passing an amount of minutes to the settings object.
A required setting for the middleware is the
accessToken that you use in the Bot Framework settings. Optional settings are
fields (array of fieldnames) and
expireMinutes (number of minutes to cache data).
const facebook = ;bot;bot;
Facebook uses referrals, optins and postbacks to send a custom payload to your chatbot. We can use this payload to trigger a specific dialog without having to start a textchat first. With the CallbackRecognizer you are able to map a dialog to a specific referral-, postin- or postback payload.
const facebook = ;bot;// When users opensbot;
It is possible to retrieve all values from the calback object by retrieving the entity. You can retrieve the entity on the regular way, by requesting the
postback type. In this example you can see how to check the source of the referral, which can be shortlink (m.me) or ad.
if argsintent !== undefined && argsintententities !== undefinedconst entity = builderEntityRecognizer; // or 'postback' / 'optin'console; //SHORTLINK or AD
Adding a Message Tag allows you to send it outside the 24+1 window, for a limited number of use cases (shipping update, reservations, and issue resolution), per Messenger Platform policy. You can find all possbile tags in the Message Tag documentation.
const facebook = ;bot;