Skip to content

Commit

Permalink
Merge pull request #20 from webus/examples
Browse files Browse the repository at this point in the history
Examples
  • Loading branch information
cama authored Aug 31, 2017
2 parents 0ec486a + 4b2af74 commit 7f7c104
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 1 deletion.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 2 additions & 0 deletions examples/basic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
package-lock.json
3 changes: 3 additions & 0 deletions examples/basic/env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FB_PAGE_ACCESS_TOKEN=
FB_VERIFY_TOKEN=
APIAI_ACCESS_TOKEN=
2 changes: 1 addition & 1 deletion examples/basic/lib/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const BotStack = require('../../../index.js');
const BotStack = require('botstackjs');

class DemoApp extends BotStack {}

Expand Down
18 changes: 18 additions & 0 deletions examples/basic/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit 7f7c104

Please sign in to comment.