There's not too many practical examples out there of Nodejs bots built using Microsoft Bot Framework, so here's one. I've tried to leave comments to explain what's going on.
I will be posting a full tutorial on how to build this from scratch for beginners along with explanations, so look out for updates (or you can follow my Twitter).
Feel free to leave feedback. I also take requests for bots! You can tweet me or email me at [email protected] :)
Go and get a Bing Web Search API Subscription Key from here and set BINGNEWSKEY in the code with your own subscription key.
Install and open up Bot Framework Emulator. In the fields at the top, your local port should be 9000, emulator url should be http://localhost:9000/ and bot url should be http://localhost:3978/api/messages.
Navigate to the folder with the bot in the command line. Run npm install
to install the required node modules, then run node app.js
to run the bot. You can now start chatting with the bot through the emulator.
Go and get a Bing Web Search API Subscription Key from here and set BINGNEWSKEY in the code with your own subscription key.
You will need to create a bot on Microsoft Bot Framework and replace the appId and appPassword in the code with your bot's appId and appPassword. You'll then need to add the Facebook Messenger channel and follow the instructions to configure your bot for Messenger (it includes making a Facebook page, etc). When configuring your bot for Messenger channel, you'll need to provide an endpoint for your bot when setting up the webhook in the Facebook developer portal. You can either publish the bot on a web host of your choice (e.g. Azure or Heroku), or use ngrok. Your webhook url in the Facebook developer portal can then be set to the /api/messages endpoint of your website or ngrok url. If you use ngrok, run ngrok http -host-header=rewrite 9000
in the command prompt and then set up the webhook in Facebook.
I'll be posting a more detailed tutorial of this in future.
I'll be implementing the following features at some point in the future:
- Using LUIS, Microsoft's NLP processing engine for advanced dialogs
- Daily notifications
Feel free to contribute to this project! Use the following guidelines:
- Fork the repo on GitHub
- Clone the project to your own machine
- Commit changes to your own branch
- Push your work back up to your fork
- Submit a Pull request online so that I can review your change