wit-ai / node-wit

Node.js SDK for Wit.ai
Other
2.05k stars 485 forks source link

More structured and testable integration with FB messanger? #22

Open hunkim opened 8 years ago

hunkim commented 8 years ago

I really like Wit.ai and the messenger.js example. Thanks a lot for that. However, since bot engine, Facebook API, and (express) server is all in one file, it's hard to test each feature.

I basically, separate them into three files and make them testable individually: jest, bot and server with a simple payload.

Jest

 npm test

Bot testing

 $WIT_TOKEN=insert_token_here node bot

Server testing

First, run the server

 $WIT_TOKEN=insert_token_here node index

In other shell, fire this command:

 $curl -X POST -H "Content-Type: application/json" -d @__tests__/msg.json http://localhost:8445/webhook

Also, I added a quick button and app.json to quickly deploy the bot server in the Heruko effortlessly.

Are you potentially interested having this change as a PR to a node-wit subdirectory (like examples)? I would be more than happy to clean up the code, send a PR and get your comments.

Please take a look at the preliminary code at https://github.com/hunkim/Wit-Facebook.

DiegoRBaquero commented 8 years ago

Check this: Send API methods wrapped: https://github.com/DiegoRBaquero/node-fb-messenger

Might find it useful

hunkim commented 8 years ago

@DiegoRBaquero Very nice. I'll definitely use this wrapper.

hunkim commented 8 years ago

@DiegoRBaquero BTW, I'm also working on Python. Do you know something like this nice FB wrapper for Python? Can you make one?

Cheers!

DiegoRBaquero commented 8 years ago

@hunkim I don't really do python, sorry.