From 4d866876ae58a17d9887da68e84278e552570b99 Mon Sep 17 00:00:00 2001 From: webus Date: Wed, 23 Aug 2017 20:42:19 +0300 Subject: [PATCH 1/2] update examples section in README file --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/README.md b/README.md index 26c4d0b..099ab36 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,47 @@ That's why we've open sourced our Facebook Messenger node.js code base so you ca * `npm install botstack` * set API keys in env_tmpl +## Example +Create `index.js` file with this content: + +```js +const BotStack = require('botstack'); + +class ExampleBot extends BotStack {}; + +const bot = new ExampleBot('example-bot'); +bot.startServer(); +``` +Before the start of the bot, we need to set a few environment variables: +```bash +FB_PAGE_ACCESS_TOKEN, FB_VERIFY_TOKEN, APIAI_ACCESS_TOKEN +``` +If you don't want to set environment variables explicitly, you can use the `dotenv` library. + +Example: + +1. Create `.env` file in the root folder of your project +Example: +```bash +FB_PAGE_ACCESS_TOKEN= +FB_VERIFY_TOKEN= +APIAI_ACCESS_TOKEN= +``` +2. Create JS file: +```js +require('dotenv').config(); +class ExampleBot extends BotStack {}; + +const bot = new ExampleBot('example-bot'); +bot.startServer(); +``` + +3. Run +```bash +node index.js +``` +Other examples you can find in the `examples` folder of this repository. + ## Features * Emjoi Support * Configurable 'Greeting, Get Started Button & Action Menu' From 4b2af74d4413ead34422f3491f881e3f6a0bc0a9 Mon Sep 17 00:00:00 2001 From: webus Date: Wed, 23 Aug 2017 20:49:26 +0300 Subject: [PATCH 2/2] update basic example` --- examples/basic/.gitignore | 2 ++ examples/basic/env | 3 +++ examples/basic/lib/app.js | 2 +- examples/basic/package.json | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 examples/basic/.gitignore create mode 100644 examples/basic/env create mode 100644 examples/basic/package.json diff --git a/examples/basic/.gitignore b/examples/basic/.gitignore new file mode 100644 index 0000000..d5f19d8 --- /dev/null +++ b/examples/basic/.gitignore @@ -0,0 +1,2 @@ +node_modules +package-lock.json diff --git a/examples/basic/env b/examples/basic/env new file mode 100644 index 0000000..84138d6 --- /dev/null +++ b/examples/basic/env @@ -0,0 +1,3 @@ +FB_PAGE_ACCESS_TOKEN= +FB_VERIFY_TOKEN= +APIAI_ACCESS_TOKEN= \ No newline at end of file diff --git a/examples/basic/lib/app.js b/examples/basic/lib/app.js index a2473a6..d68feb4 100644 --- a/examples/basic/lib/app.js +++ b/examples/basic/lib/app.js @@ -1,4 +1,4 @@ -const BotStack = require('../../../index.js'); +const BotStack = require('botstackjs'); class DemoApp extends BotStack {} diff --git a/examples/basic/package.json b/examples/basic/package.json new file mode 100644 index 0000000..b9f24f6 --- /dev/null +++ b/examples/basic/package.json @@ -0,0 +1,18 @@ +{ + "name": "basic", + "version": "1.0.0", + "description": "", + "main": "index.js", + "directories": { + "lib": "lib" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "botstack": "^0.1.3" + } +}