How to use a single webhook for multiple messenger apps/bots? - facebook

I'm developing different chatbots for different fb pages but I only have one server to run them.
For the first chatbot I am using https://mydomain/webhook as webhook and everything works fine, all the messages are sent to the 443 port and my program process them. Now I was wondering what should be the webhook for my second chatbot. My idea was to open a https connection on another port and use https://mydomain/webhook:myport as webhook so that each bot listen on a different port and each webhook points to them accordingly.
Unfortunately when I try to validate my webhook from the facebok developer platform I got a 404 not found response. I also tried to use the same webhook on the same port (443) and I get 403 forbidden response.

You can use the exact same webhook, same port and all, for multiple facebook messenger bots. Each payload of messaging events sent to your webhook will be sorted into a list of pages that the messages are for. You can write code to handle each page's payload differently after it has hit your webhook.

My error was to add the port number after "/webhook" while the port number should go after the ip address "https://mydomain". In case anyone else was wondering, yes you can use the same webhook for different messenger apps, just use different ports.

You can receive your response in 443 and then redirect to your specified port by using proxy pass in your server's conf.
server {
listen 443;
server_name mydomain/webhook2;
location /{
proxy_pass http://127.0.0.1:yourportname;
}
}

Related

We need to change our URLs without port and receive requests to the specific application

We have following URLs like
http://testserver1.com:port1
http://testserver2.com:port2
Each URL is pointing to different application on the Windows Server.
What we need to do is that we need to change the URL like http://testserver1.com instead of http://testserver1.com:port1 and it should be forwarded to the application serving port1. We do not want users to enter port number with the URL.
And if we type http://testserver2.com instead of http://testserver2.com:port2 also it should be forwarded to the application serving port2.
How can we do this with Windows Firewall - Inbound Rules and IIS. Can somebody help?
We have tried to add first Inbound Rule under Windows Firewall but we have no idea how to do the rest to forward such incoming requests to the correct application serving the specific port.

Keycloak API execute-actions-email sending http email

I'm running Keycloak and it works great. The only thing I'd like to change is when the execute-actions-email API is called it sends the email but the link uses HTTP. I'd like it to be HTTPS. How does KC determine it should use HTTP? Is it because I made the API call over HTTP to trigger the request? Doe it get it from the client config?
It uses whatever protocol was used to make the RESTfull call; just connect to KC on port 8443 (default SSL port) and it'll send the email with a link that uses HTTPS.

REST API with Single Page Application over HTTPS on Firefox only

I am developing a web service using REST API. This REST API is running on port 6443 for HTTPS. Client is going to be a Single page application running on port 443 for HTTPS on same machine. The problem I am facing is:
While I hit the url say: https://mymachine.com/new_ui I get certificate exception for an invalid certificate because I use a self signed one, so mymachine.com:443 gets added to server exception. But still requests doen't go to REST API as they are running on https://mymachine.com:6443/restservice. If I manually add mymachine.com:6443 to server exception on firefox it works but it will not be the case in production for customers.
Some options that I thought are:
1. Give another pop up and ask to add REST server on port 6443 exception too.But this doesn't look proper as why an end user should accept the cerf for same domain twice. Also REST api server port can change.
Can we programmatically add exception for domain and both the ports in one shot? Ofcourse with the consent of the user. 3. Use a reverse proxy. But then its going to have memory footprint on our system. Also it will be time consuming.
Please suggest some options. How do I deal with it. Thank you

XMPP over BOSH - jappix.com replies always with empty body

I am implementing XMPP service in the browser using BOSH. I use JAXL library. I am able to manage the connection over BOSH to my localhost server (ejabberd). The session is started and the user is authenticated with no problem. However, when I just change the BOSH host to jappix.com, the very first response from the server is only empty body. Even if I repeat the request (according to XEP-206) I still get only empty body so I'm unable to perform any other actions.
So that's my question: Is it possible to use jappix.com to handle my BOSH requests? Are there any limitations? How can I fix this issue? I'll provide more information if needed.
I am the Jappix.com owner!
Your question does not concern our service directly but more likely a node-xmpp-bosh - the BOSH server we are running - bug (?) that you can report on http://code.google.com/p/node-xmpp-bosh/

How to test Facebook Real-time updates

In order to publish real-time updates to my app, Facebook needs needs to perform a post request to my server.
Problem is, my server is my home computer and not publicly addressable from the internet. Bringing a server live to implement this sounds like it could be a pain... can't attach debugger, fiddler etc....
So what's the best way to test the Http Endpoint? Integration tests that simulate the Facebook server? Fiddling with firewalls/NAT to try and get Facebook talking to my home computer?
Any ideas?
You can use ngrok - https://ngrok.com/ - free (pay-what-you-can) service that does exactly what you need. Localtunnel service is down and the developers also recommend ngrok.
In the past, I've used LocalTunnel to do this. It's a nice wrapper around an SSH tunnel and it effectively assigns you a subdomain at localtunnel.com pointing to a port on your localhost.
So basically, when you run it it will spit back an externally accessible sub domain name like xyz.localtunnel.com who's port 80 will point a port you specify on your local box.
You can find it at: http://progrium.com/localtunnel/
It's really great for testing various pubsubhubbub subscription feeds (like Facebook's).
OK! I think NAT should be the best bet and I don't see a reason for it not to work. You should try it out.
It was actually pretty easy - Logged into my home router, set up port forwarding on port 80 to the local IP of my computer, put an exception in windows firewall for port 80. and then navigate to my public IP address in the browser.
Implement the receiver samples at: https://github.com/facebook/real-time/tree/master/samples
The only answer is to get a webserver that is publicly accessible for real-time updates to be able to call back to.
There's lots of free webhosts that allow server-side scripting. And there's lots of paid for webhosts out there too. Stackoverflow is really not the place to get leads on where/when/why/howmuch for web hosting.
No you can't use ngrok only to simulate facebook realtime update since you must make a call to facebook servers with your ngrok adress to validate it (tell me if you find out how to do this :p ).
I use an openshift server to receive facebook realtime and then post evry json data received from facebook to my ngrok adress. So the process is
set up an openshift server to receive facebook notifications
Facebook sends notifications to your openshift
your openshift sends datas (as received) to your ngrok adress
And if you must receive facebook notifications on a local website (like www.website.dev/fb-notifications/) then create a script in your localhost folder which receives openshift posts (let's call it tunelscript.php). the process will be
set up an openshift server to receive facebook notifications
Facebook sends notifications to your openshift
your openshift sends datas (as received) to your tunel script via your ngrok adress (perso.ngrok.com/tunelscript.php)
Relay datas from your tunelscript to your local website (tunelscript.php => www.website.dev/fb-notifications/)
That's Tuneling B-)