GithubHelp home page GithubHelp logo

messenger-bot-samples's People

Contributors

dependabot[bot] avatar embee8 avatar gpwclark avatar heyliger avatar jlamsa avatar joeangel avatar michaelterk avatar schvenk avatar shprink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

messenger-bot-samples's Issues

Documentation for extensions

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!

Messenger App detected as Web (again)

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)

Messenger app not detected

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.
Screenshot_2019-05-17-14-26-40-155_com facebook orca

The method callThreadAPI is missing

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.

The bot is not working

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

Not able to run the chat extension on Heroku

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?

Chat extensions example is broken again

The messenger chat bot on https://www.messenger.com/t/MessengerTaskBot doesn't appear to be able to load the webview extension:
image

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.

chat extensions example is broken

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.

Comments uncompatible with documentation

Official docs clearly say:
msg_issue

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.

gui-webview for those who are not familiar with Ract

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?

call MessengerExtensions.requestCloseBrowser function from js file?

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?

Heroku build showing Internal Server Error for Messenger Extension

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!

screen shot 2017-07-13 at 12 11 16 pm

listId is not defined

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)

config:set

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

Internal server running the chat-extensions sample code

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)

`${SERVER_URL}/` seems to be not resolving properly

@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] }
}
}

Can you publish project structure

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.

OAuthException

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 ?

Please try in Messenger App

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.