
Show HN: Turned Facebook Messenger into a JavaScript REPL - peralmq
http://github.com/peralmq/bot-wat
======
emirozer
Cool idea! But man, Gary Bernhardt's WAT talk, even though i saw it at least
10 times, still cracks me up...

~~~
jeremiep
His "Useing You're Type's Good" talk is also wonderful, also made me laugh to
tears!

[1]: [https://www.destroyallsoftware.com/talks/useing-youre-
types-...](https://www.destroyallsoftware.com/talks/useing-youre-types-good)

~~~
Cyph0n
That was hilarious! Anyone know of similar PL warts talks?

------
tomsmeding
Happy to see that it uses the safe-eval library, which appears to fix code
injection issues. Haven't checked that well though.

~~~
_RPM
"safe eval". What does that even mean?

~~~
aeharding
"safe-eval lets you execute JavaScript code without having to use the much
discouraged and feared upon eval(). safe-eval has access to all the standard
JavaScript API of the underlying engine. It is implemented using node's vm
module." [1]

[1] [https://www.npmjs.com/package/safe-
eval](https://www.npmjs.com/package/safe-eval)

~~~
dsp1234
It's important to note that running code in vm.runInNewContext is not advised
for 'untrusted code' according to the documentation. So probably not good to
let random people use this bot.

"script.runInNewContext() is quite useful, but safely running untrusted code
requires a separate process."[0]

[0] -
[https://nodejs.org/api/vm.html#vm_script_runinnewcontext_san...](https://nodejs.org/api/vm.html#vm_script_runinnewcontext_sandbox_options)

------
lacker
Do you have a link to the bot running in Messenger? The
[https://www.facebook.com/gdY7MU/messages/](https://www.facebook.com/gdY7MU/messages/)
link in the repo appears to be broken.

~~~
peralmq
Hey, yes, sorry, I had misunderstood the Facebook Messenger bot review
process. Thought that it was enough to publish the Facebook page in order to
be able to receive and send messages to external people. Now the page can
receive messages but those messages never make it to the server where the bot
is located, and hence no response ever makes it back to you.. :(

Good news is that if you follow Facebook's guide to create a Messenger bot you
can easily deploy this code and play around with it yourself. It works great
to receive and send messages but only for the owner of the page/bot :)

I'll update you if I get the required permission from Facebook and the bot
becomes publicly accessible.

------
asimuvPR
Hilarious! Now all I need is a bot that reads my messenger feed and executes
commands. Never having to leave Facebook. 0_o

~~~
tedmiston
I thought you were going to say responds for you so you never have to _get on_
Facebook.

~~~
asimuvPR
In al seriousness, I don't really use Facebook for anything and only keep an
account to communicate with my daughter's teachers. But as ASIMUV grows people
are always asking about it on Facebook. Now I'm planning on using it as part
of the community outreach program. And I'm not even sure how it works
anymore... D:

------
goblin89
Messenger Platform docs happen to showcase very specific acceptable examples
of what bots are expected to do[0]. An app like this doesn’t look likely to be
approved to be publicly accessible.

Does anyone have experience getting FB’s approval for a Messenger bot?

[0] [https://developers.facebook.com/docs/messenger-
platform/app-...](https://developers.facebook.com/docs/messenger-platform/app-
review#examples_acceptable)

------
MaddoScientisto
Is sending and receiving messages through facebook messenger still limited to
the official app or did they add back an API to replace the old XMPP
interface?

~~~
codegefluester
Facebook launched an API for this at F8 this year
[https://developers.facebook.com/docs/messenger-
platform](https://developers.facebook.com/docs/messenger-platform)

~~~
kevincox
I think that is different from what he is asking. I believe MaddoScientisto
was talking about and API that could be used to create unofficial clients. The
API you provided appears to be designed to create bots, and insufficient for
custom clients.

------
atishay811
Is it time to build free internet over facebook zero and their internet.org? A
free proxy server and an android app should be able to do that right?

------
abdelhai
That's similar to the Python interpreter bot "pypie" that we made a couple of
weeks ago for our Slack group "#devchat".

[https://github.com/devolio-devchat/pypie](https://github.com/devolio-
devchat/pypie)

Bots are awesome!

------
amelius
Or you could just open the developer console ...

~~~
mbrock
Where's the JavaScript REPL on iPhone Safari?

~~~
nacs
Exactly. Now when I need a JS REPL on my iPhone, I can just think "Facebook!"
and chat with the bot..

Alternative:
[http://thumbsnap.com/s/rd1sV73V.png?0421](http://thumbsnap.com/s/rd1sV73V.png?0421)

