Example bots to demonstrate best practices for the Messenger Platform.
fbsamples / messenger-bot-samples Goto Github PK
View Code? Open in Web Editor NEWMessenger Bot Samples
License: Other
Messenger Bot Samples
License: Other
Example bots to demonstrate best practices for the Messenger Platform.
Any ideas how I can resolve this error? The app won't run in Heroku at the minute but I can't find a solution to the problem
2017-10-17T20:22:52.189838+00:00 app[web.1]: at returnedFn (/app/node_modules/ejs/lib/ejs.js:555:17) 2017-10-17T20:22:52.189838+00:00 app[web.1]: at tryHandleCache (/app/node_modules/ejs/lib/ejs.js:203:34) 2017-10-17T20:22:52.189839+00:00 app[web.1]: at View.exports.renderFile [as engine] (/app/node_modules/ejs/lib/ejs.js:412:10) 2017-10-17T20:22:52.189840+00:00 app[web.1]: at View.render (/app/node_modules/express/lib/view.js:128:8) 2017-10-17T20:22:52.189841+00:00 app[web.1]: at tryRender (/app/node_modules/express/lib/application.js:640:10) 2017-10-17T20:22:52.189842+00:00 app[web.1]: at Function.render (/app/node_modules/express/lib/application.js:592:3) 2017-10-17T20:22:52.189842+00:00 app[web.1]: at ServerResponse.render (/app/node_modules/express/lib/response.js:966:7) 2017-10-17T20:22:52.189843+00:00 app[web.1]: at /app/routes/index.js:15:7 2017-10-17T20:22:52.189844+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5) 2017-10-17T20:22:52.189845+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/route.js:137:13) 2017-10-17T20:22:52.189845+00:00 app[web.1]: at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3) 2017-10-17T20:22:52.189846+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5) 2017-10-17T20:22:52.189847+00:00 app[web.1]: at /app/node_modules/express/lib/router/index.js:281:22 2017-10-17T20:22:52.189847+00:00 app[web.1]: at Function.process_params (/app/node_modules/express/lib/router/index.js:335:12) 2017-10-17T20:22:52.189848+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/index.js:275:10) 2017-10-17T20:28:02.186270+00:00 heroku[router]: at=info method=GET path="/" host=serene-bayou-29655.herokuapp.com request_id=f3391ffa-ca7f-4789-ad56-aa2d7aceace7 fwd="78.19.206.245" dyno=web.1 connect=1ms service=5ms status=500 bytes=404 protocol=https 2017-10-17T20:28:02.184081+00:00 app[web.1]: GET / 500 0.484 ms - 148 2017-10-17T20:28:02.190127+00:00 app[web.1]: ReferenceError: /app/views/index.ejs:22 2017-10-17T20:28:02.190131+00:00 app[web.1]: 20| window.attachApp( 2017-10-17T20:28:02.190132+00:00 app[web.1]: 21| context.psid, 2017-10-17T20:28:02.190133+00:00 app[web.1]: >> 22| <%= listId %>, 2017-10-17T20:28:02.190134+00:00 app[web.1]: 23| "<%= socketAddress %>", 2017-10-17T20:28:02.190134+00:00 app[web.1]: 24| context.thread_type); 2017-10-17T20:28:02.190135+00:00 app[web.1]: 25| }, function error(err) { 2017-10-17T20:28:02.190136+00:00 app[web.1]: 2017-10-17T20:28:02.190142+00:00 app[web.1]: listId is not defined 2017-10-17T20:28:02.190144+00:00 app[web.1]: at eval (eval at compile (/app/node_modules/ejs/lib/ejs.js:524:12), <anonymous>:22:26)
Messenger is being updated as of 15 August 2019 and new versions of the app will drop support for:
Full changelog
Does this effectively render the Shopping List bot (chat extension example) unusable?
Hello,
I followed all steps included inside the readme for chat-extensions. But I always get the viewing outside messenger page. I tried on two different phones.
I used those commands
heroku create
heroku addons:create heroku-postgresql
heroku config:set WEBHOOK_TOKEN='{MYSECRETTOKEN}'
heroku config:set APP_URL='{MYAPPURL}'
git subtree push --prefix chat-extensions/ heroku master
# I configured the app and the page details before executing those commands
heroku config:set PAGE_ACCESS_TOKEN='{MYAPPTOKEN}'
curl -X POST -H "Content-Type: application/json" -d '{ "whitelisted_domains":["{MYAPPURL}"]}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token={MYAPPTOKEN}"
I also whitelisted my app inside page setiings and sucessfully subscribe my webhook to the page. The bot can sends message and even display the regular heroku website when the app is destroyed.
I am using a simple node.js project without babel and other configurations.
I have a feedback.js file in routes and feedform.ejs file.
I have added messenger extensions sdk in feeback.ejs file. In the following way :
<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'));
window.extAsyncInit = function() {
// the Messenger Extensions JS SDK is done loading
var isSupported = MessengerExtensions.isInExtension();
MessengerExtensions.getContext('************',
function success(result){
document.getElementById("psidid").value = result.psid;
},
function error(result){
//alert("json str "+JSON.stringify(result));
}
)
};
</script>
I am able to retrieve the psid as well. In the feedback form in post action I am calling a function in a js file.
eg :
<form method="post" action="/feeback/submit">
<table cellpadding="11">
<tr>
<td class="label">First Name</td><td>: <input type="text" name="fname" required></td>
</tr>
<tr>
<td class="label">Last Name</td><td>: <input type="text" name="lname" required></td>
</tr>
</table>
</form>
In app.js file :
app.post('/feeback/submit', feedback.submit);
I am calling a function( submit ) in feedback.js file:
In the function I am saving the form data to Database and I should be able to close the webview also on successfully saving the data.
How can I acheive it?
I used the below method but I am getting MessengerExtensions is not defined error :
MessengerExtensions.requestCloseBrowser(function success() {
// webview closed
user.doDataResponse(psid, message);
}, function error(err) {
// an error occurred
});
I tried calling using window.MessengerExtensions.requestCloseBrowser but getting window is undefined error.
Please tell me how can i resolve the issue?
Please can you provide examples for developers who are not familiar with React techniques?
Simple DOM and CSS documentation to start with will be more than enough.
Or simply may you create another version of gui-webview which can run on PCs (instead of messenger only) so we could inspect DOMs and Classes on the browser and find our way through it?
@schvenk @tcsapunaru
my code can be found https://github.com/RohitBansal18/chatbot
This is not a issue in the sample example bot. I am creating new bot and following example step by step but stuck at GET_STARTED only. pls help.
Heroku Console Log:
at=info method=POST path="/webhook" host=insurancetravel-bot.herokuapp.com request_id=aa3a62e2-355b-402f-83bc-25e98b92e4e8 fwd="173.252.86.214" dyno=web.1 connect=1ms service=52ms status=200 bytes=196 protocol=https
{ data: { object: 'page', entry: [ [Object] ] } }
{ messagingEvent:
{ recipient: { id: '122775108435220' },
timestamp: 1507433054356,
sender: { id: '1493046944115720' },
postback: { payload: '{"type":"GET_STARTED"}', title: 'Get Started' } } }
Webhook postback Received
Successfully sent message to messages endpoint: {"recipient_id":"1493046944115720"}
Failed calling Messenger API endpoint messages 400 Bad Request { message: '(#100) Invalid data',
type: 'OAuthException',
code: 100,
error_subcode: 2018032,
fbtrace_id: 'Eqhka4Fpv7G' } {}
{
recipient: { id: '1493046944115720' },
message: { attachment:
{ type: 'template', payload: [Object] }
}
}
Hi all,
I am looking a starter for express app using es7, yarn and some module.., and I see the perfect structure in here. Can you publish its?
Thanks.
The method callThreadAPI() is missing in api.js at the projects 'gui-webview' and 'account-linking'
Calls to the method that are failing
thread-setup.js
const setDomainWhitelisting = () => {
api.callThreadAPI(
{
setting_type: 'domain_whitelisting',
whitelisted_domains: [SERVER_URL],
domain_action_type: 'add',
}
);
};
const setPersistentMenu = () => {
api.callThreadAPI(messages.persistentMenu);
};
Throwing the following error
TypeError: _api2.default.callThreadAPI is not a function
at Object.setDomainWhitelisting (C:/Users/gmartinez/Downloads/messenger-bot-samples/gui-webview/messenger-api-helpers/thread-setup.js:30:7)
at Object. (C:/Users/gmartinez/Downloads/messenger-bot-samples/gui-webview/app.js:84:13)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at loader (C:\Users\gmartinez\Downloads\messenger-bot-samples\gui-webview\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (C:\Users\gmartinez\Downloads\messenger-bot-samples\gui-webview\node_modules\babel-register\lib\node.js:154:7)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
error Command failed with exit code 1.
Seems like the page was unpublished
Failed calling Messenger API endpoint thread_settings 500 Internal Server Error { message: 2018-08-17T10:41:46.442834+00:00 app[web.1]: 'Tried accessing nonexisting field (whitelisted_domains) on node type (Page)',
I am getting this error when i deploy my app to heroku
I get 'Please try in messenger app' even if I am on the Messenger App. Regardless, with the new update to 2.1, shouldn't this work on anything (browser)?
If I view Victoria Belle using latest Messenger app on iOS, 75% of the time the 'Gift Preferences menu button' webview won't load and I get the 'Please Try in Messenger App'. Maybe a bug or the code needs to be updated to reflect recent changes? The compact webview for view details seems to work.
Currently experiencing the same issue on iOS 12.2 on iPhone Xs. It keeps telling me to access the service via the native app, which is where I am
I have followed the given instructions, yet the bot did function properly . it does not show any webview menu or anything . but it can receive and send messages
I followed the readme and when I type a message on my FB page I get this log on heroku:
2017-05-11T15:32:17.003168+00:00 app[web.1]: type: 'OAuthException',
2017-05-11T15:32:17.003169+00:00 app[web.1]: code: 2500,
2017-05-11T15:32:17.003171+00:00 app[web.1]: fbtrace_id: 'F/QCZ7327U3' } {}
2017-05-11T15:32:17.003351+00:00 app[web.1]: Retrying Request: 5 left
2017-05-11T15:32:17.033694+00:00 app[web.1]: Failed calling Messenger API endpoint messages 400 Bad Request { message: 'An active access token must be used to query information about the current user.',
I re generated the Page Access Token but same error. Any idea ?
I'm getting the following error:
017-05-07T01:04:38.961288+00:00 app[web.1]: ReferenceError: /app/views/index.ejs:22
2017-05-07T01:04:38.961292+00:00 app[web.1]: 20| window.attachApp(
2017-05-07T01:04:38.961293+00:00 app[web.1]: 21| context.psid,
2017-05-07T01:04:38.961293+00:00 app[web.1]: >> 22| <%= listId %>,
2017-05-07T01:04:38.961294+00:00 app[web.1]: 23| "<%= socketAddress %>",
2017-05-07T01:04:38.961295+00:00 app[web.1]: 24| context.thread_type);
2017-05-07T01:04:38.961296+00:00 app[web.1]: 25| }, function error(err) {
2017-05-07T01:04:38.961296+00:00 app[web.1]:
2017-05-07T01:04:38.961297+00:00 app[web.1]: listId is not defined
2017-05-07T01:04:38.961298+00:00 app[web.1]: at eval (eval at compile (/app/node_modules/ejs/lib/ejs.js:524:12), <anonymous>:22:26)
2017-05-07T01:04:38.961299+00:00 app[web.1]: at returnedFn (/app/node_modules/ejs/lib/ejs.js:555:17)
2017-05-07T01:04:38.961300+00:00 app[web.1]: at tryHandleCache (/app/node_modules/ejs/lib/ejs.js:203:34)
2017-05-07T01:04:38.961302+00:00 app[web.1]: at View.render (/app/node_modules/express/lib/view.js:128:8)
2017-05-07T01:04:38.961301+00:00 app[web.1]: at View.exports.renderFile [as engine] (/app/node_modules/ejs/lib/ejs.js:412:10)
2017-05-07T01:04:38.961302+00:00 app[web.1]: at tryRender (/app/node_modules/express/lib/application.js:640:10)
2017-05-07T01:04:38.961303+00:00 app[web.1]: at Function.render (/app/node_modules/express/lib/application.js:592:3)
2017-05-07T01:04:38.961304+00:00 app[web.1]: at ServerResponse.render (/app/node_modules/express/lib/response.js:966:7)
2017-05-07T01:04:38.961304+00:00 app[web.1]: at /app/routes/index.js:15:7
2017-05-07T01:04:38.961305+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2017-05-07T01:04:38.961306+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/route.js:137:13)
2017-05-07T01:04:38.961306+00:00 app[web.1]: at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3)
2017-05-07T01:04:38.961307+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2017-05-07T01:04:38.961308+00:00 app[web.1]: at /app/node_modules/express/lib/router/index.js:281:22
2017-05-07T01:04:38.961308+00:00 app[web.1]: at Function.process_params (/app/node_modules/express/lib/router/index.js:335:12)
2017-05-07T01:04:38.961309+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/index.js:275:10)
Would like to revisit this. Currently experiencing the same problem on iOS 12 on iPhone X.
This may be out of scope, but why initialize via Messenger extension? What would be steps to go about decoupling this from the Messenger extension, and thus getting rid of the root issue altogether? Thanks. @embee8
Originally posted by @andrewkmin in #31 (comment)
Official docs clearly say:
However messenger-bot-samples/account-linking/routes/webhooks.js:65-66
have the following two lines:
// Iterate over each messaging event
pageEntry.messaging.forEach((messagingEvent) => {
I find the lines very misleading.
I followed all the instructions of chat-extensions but when I try to invite other friends to edit the list then on the mobile I get a message like
Any idea what's wrong?
Also my heroku hosting is giving me this error "Internal Server Error"
Link: https://still-plateau-77702.herokuapp.com/
Can I use c9.io instead of Heroku ?
And what wil change when i use c9.io?
I tried running the messenger extension following the github tutorial from their facebook's demo messenger extension https://github.com/fbsamples/messenger-bot-samples/tree/master/chat-extensions
I did all the steps exactly as mentioned but when I am opening the heroku url, its showing me internal server error and the /webhook route of url is showing me wrong token. I am not able to figure out where I am going wrong. Any help is appreciated. Thanks!
This seems a little odd
I ran the entire tutorial to set-up my own Tasks bot.
When I click 'Create a List' on messenger the webview pops up and finishes loading but when it finishes all I see is a blank page.
I also tried from two iPhones with two different facebook accounts to use Facebook's Tasks bot and it also gives a blank page when clicking 'Create a List'.
I find it very difficult to debug the issue as I cannot click that url from a desktop browser, as it returns a message that this page is only supported on iOS or Android.
The messenger chat bot on https://www.messenger.com/t/MessengerTaskBot doesn't appear to be able to load the webview extension:
When opening the iframe, the following error shows up in the client logs:
Load denied by X-Frame-Options: https://www.messenger.com/t/MessengerTaskBot?fb_iframe_origin=https%3A%2F%2Fwww.messenger.com does not permit framing.
This seems to have started happening today (Jan 18, 2018) and did not seem to happen yesterday (Jan 17, 2018). I also do not seem to be the only one to experience this issue in various cases:
https://stackoverflow.com/questions/48321555/fb-messenger-webview-x-frame-options-deny-ruining-webview
Tested on Firefox 57.0.4 (64-bit), Chrome Version 63.0.3239.132 (Official Build) (64-bit) and Vivaldi 1.13.1008.40 (Stable channel) (64-bit), all on Mac OSX El Capitan Version 10.11.6.
Additional note: although the symptoms are similar to #15, it doesn't seem to be the same cause.
Hi,
I am a more or less new to the Facebook messenger platform and this project seems to be an advanced assembly of its features. I was wondering if would be possible that you folks create a more detailed documentation about how it works rather than just what technologies and libraries were utilized.
Thanks!
We are still using the thread_settings API, which was deprecated a long long loooonnngg time ago. We should update to use the messenger_profile API
I ran the gui-webview example successfully. On messenger, the webview loaded the React app just fine on my Android 6.0 device while failing to render on my Android 4.4.
when i run following command on my terminal it says those
heroku config:set APP_URL='https://myapp.herokuapp.com'
» Error: Missing required flag:
» -a, --app APP app to run command against
» See more help with --help
I was testing the chat-extensions feature but on Heroku I was not able to run it.
It is saying "Internal Server Error"
here are the Heroku log details:
0mGET / �[31m500 �[0m0.743 ms - 148�[0m
2017-05-24T22:03:06.236808+00:00 app[web.1]: ReferenceError: /app/views/index.ejs:22
2017-05-24T22:03:06.236810+00:00 app[web.1]: 20| window.attachApp(
2017-05-24T22:03:06.236811+00:00 app[web.1]: 21| context.psid,
2017-05-24T22:03:06.236811+00:00 app[web.1]: >> 22| <%= listId %>,
2017-05-24T22:03:06.236812+00:00 app[web.1]: 23| "<%= socketAddress %>",
2017-05-24T22:03:06.236812+00:00 app[web.1]: 24| context.thread_type);
2017-05-24T22:03:06.236813+00:00 app[web.1]: 25| }, function error(err) {
2017-05-24T22:03:06.263336+00:00 heroku[router]: at=info method=GET path="/" host=cryptic-cliffs-96893.herokuapp.com request_id=c4286f42-7c3b-4eed-ae7b-cf20f215fcc9 fwd="158.106.198.94" dyno=web.1 connect=0ms service=2ms status=500 bytes=404 protocol=https
2017-05-24T22:03:06.236814+00:00 app[web.1]:
2017-05-24T22:03:06.236815+00:00 app[web.1]: listId is not defined
2017-05-24T22:03:06.236819+00:00 app[web.1]: at eval (eval at compile (/app/node_modules/ejs/lib/ejs.js:524:12), :22:26)
2017-05-24T22:03:06.236820+00:00 app[web.1]: at returnedFn (/app/node_modules/ejs/lib/ejs.js:555:17)
2017-05-24T22:03:06.236820+00:00 app[web.1]: at tryHandleCache (/app/node_modules/ejs/lib/ejs.js:203:34)
2017-05-24T22:03:06.236821+00:00 app[web.1]: at View.exports.renderFile [as engine] (/app/node_modules/ejs/lib/ejs.js:412:10)
2017-05-24T22:03:06.236822+00:00 app[web.1]: at View.render (/app/node_modules/express/lib/view.js:128:8)
2017-05-24T22:03:06.236823+00:00 app[web.1]: at tryRender (/app/node_modules/express/lib/application.js:640:10)
2017-05-24T22:03:06.236823+00:00 app[web.1]: at Function.render (/app/node_modules/express/lib/application.js:592:3)
2017-05-24T22:03:06.236824+00:00 app[web.1]: at ServerResponse.render (/app/node_modules/express/lib/response.js:966:7)
2017-05-24T22:03:06.236825+00:00 app[web.1]: at /app/routes/index.js:15:7
2017-05-24T22:03:06.236826+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2017-05-24T22:03:06.236826+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/route.js:137:13)
2017-05-24T22:03:06.236827+00:00 app[web.1]: at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3)
2017-05-24T22:03:06.236828+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2017-05-24T22:03:06.236828+00:00 app[web.1]: at /app/node_modules/express/lib/router/index.js:281:22
2017-05-24T22:03:06.236829+00:00 app[web.1]: at Function.process_params (/app/node_modules/express/lib/router/index.js:335:12)
2017-05-24T22:03:06.236830+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/index.js:275:10)
2017-05-24T22:03:06.315622+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=cryptic-cliffs-96893.herokuapp.com request_id=36a3cdf3-a652-4108-a73e-0549229c8d04 fwd="158.106.198.94" dyno=web.1 connect=0ms service=2ms status=200 bytes=32270 protocol=https
Anyone faced the same issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.