Node.js bot and personal assistants platform. Boilerplate, start point, tools, best practices for building bots and personal assistants.
This is a Node.js platform for bots (boilerplate and start point). Implemented on top of Express, which is used only for routing, so it's easily can be changed. Platform in this case is a boilerplate, set of tools, architecture and best practices for bot building.
What's implemented.
Be sure that you replaced keys in /keys/ folder. To download json with keys:
/keys/google.json
.Please, replace app.yaml
and app-dev.yaml
files and provide listed keys. If you use different environments (live/staging/dev), don't forget to specify different keys. Right now there are only two environments: development and production.
Example of app.yaml
file:
runtime: custom
vm: true
env_variables:
LOGGING_LEVEL: 'debug'
APP_WIT_TOKEN: 'yourkeyhere'
APP_WIT_VERSION: '20161008'
GOOGLE_PROJECT_ID: 'youridhere'
FACEBOOK_PAGE_TOKEN: 'yourtokenhere'
NEW_RELIC_APP_NAME: 'youappname'
NEW_RELIC_LICENSE: 'yourkey'
Example of the app-dev.yaml
file:
runtime: custom
vm: true
env_variables:
LOGGING_LEVEL: 'silly'
APP_WIT_TOKEN: 'yourkeyhere'
APP_WIT_VERSION: '20161008'
MEMCACHE_PORT_11211_TCP_ADDR: 'localhost'
MEMCACHE_PORT_11211_TCP_PORT: '11211'
GOOGLE_PROJECT_ID: 'youridhere'
FACEBOOK_PAGE_TOKEN: 'yourtokenhere'
NEW_RELIC_APP_NAME: 'youappname'
NEW_RELIC_LICENSE: 'yourkey'
It's almost the same, but logging level is different and you need to provide memcached host and port. In case of app.yaml
(for production) it will be provided by Google App Engine automatically.
For building I use webpack. Please, notice that I have aliases for common libraries and files, that I use:
You can find configuration at /build/index.js
.
npm run build:dev
- build for development.npm run build:dev:watch
– build for development in watch mode.npm run start
– run production environment with keys from app.yaml
.npm run start:dev
– run development environment with keys from app-dev.yaml
.All shell scripts are used by package.json scripts, so you don't need to run it explicitly.
Node.js Bot Platform right now is easily deployable to Google App Engine.
Please, check code and folders. I'll try to add README in all folders and leave as much comments in the code as possible.
/src/bot
. There you should put all skills clusters for all IM Platforms./src/bot/skills/clusters
you should put only reusable (between different platforms) skills and skills clusters./src/bot/platforms/
you should put unique, not reusable skills and clusters.Please, check comments inside files. I use Express.
In the index.js file look at yourBotMessengerRouter
and buildRoute
functions, that add new route to Express Router. This route should be used by webhooks (like FB Messenger) or device API.
'/messenger/yourbot'
– is a url, that you need to specify in your messenger webhooks. For example https://yourbot.app.com/messenger/yourbot
.buildRoute
– just add provided routes to the Express Router.yourBotMessengerRouter
– is the most important part. There you can add or remove different services, that you want to use (for example, Google Storage, Memcached, Wit.ai and others) in your skills. Also you specify the initial Skills Cluster:Check comments inside files. In this file you should: