Date picker for Facebook Messenger bot

I know that there are various CTA cards that the Facebook bot can use, as shown here .

I really need a date picker map that can be sent to the user, where they can select a date and send it back. Is this possible with Facebook bots?

+6
source share
1 answer

Facebook messenger did not start the date and time in its templates.

But you can do this with webview help and extensions .

Follow these steps.

Create a button or generic template and place the button with

"buttons":[ { "type":"web_url", "url":"http://my_url_which_open_date_picker", "title":"Select date", "messenger_extensions": true, "webview_height_ratio": "compact" } ] 

replace the url with your url. NOTE. URL must be whitelisted. Your domain

Now on this web page you can get the userId of that particular user, and hens easily map his actions to select a date.

On your page

 <script> (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.com/en_US/messenger.Extensions.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'Messenger')); </script> 

When the Messenger Extensions JS SDK loads, it will call window.extAsyncInit and you will get userId in this function.

 <script> window.extAsyncInit = function() { // the Messenger Extensions JS SDK is done loading MessengerExtensions.getUserID(function success(uids) { var psid = uids.psid; }, function error(err) { }); }; </script> 

uids is an object containing user IDs
User id with page id with psid

You can also close the calender page when the user selects a date. This can be done with:

  <script> MessengerExtensions.requestCloseBrowser(function success() { }, function error(err) { }); </script> 
+4
source

All Articles