Skip to content

Commit

Permalink
Added a parameter to specify the domain the bot will accept messages …
Browse files Browse the repository at this point in the history
…from
  • Loading branch information
Rafael Campos committed Nov 2, 2017
1 parent 56c85b6 commit 57988d7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ SECRET=Not that secret !
# note that botkit automatically happens the path to the POST endpoint of your bot
#PUBLIC_URL=https://960eeccc.ngrok.io

# The domain the bot will accept messages from
#[email protected]

# Name used to create the webhook to register your bot against Cisco Spark
# Defaults to 'built with BotKit (development)'
#
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ First things first. Go ahead and create a Bot Account from the ['Spark for devel
Click below to quickly deploy the bot to Heroku. You will need the following information:
* Your Spark token
* Your public URL (for a Heroku deployment this would be `https://{app-name}.herokuapp.com`, where `{app-name}` is the name you chose for your Heroku app).
* The domain the bot will accept messages from, for example '@companyabc.com' or '@altus.cr'

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)

Expand Down Expand Up @@ -38,13 +39,13 @@ From a bash shell, type:
> git clone https://github.com/AltusConsulting/Spark-Broadcast-Bot.git
> cd Spark-Broadcast-Bot
> npm install
> SPARK_TOKEN=0123456789abcdef PUBLIC_URL=https://abcdef.ngrok.io SECRET="not that secret" node bot.js
> SPARK_TOKEN=0123456789abcdef PUBLIC_URL=https://abcdef.ngrok.io SECRET="not that secret" [email protected] node bot.js
```
If you're using Redis, this last command would be:

```shell
> SPARK_TOKEN=0123456789abcdef PUBLIC_URL=https://abcdef.ngrok.io SECRET="not that secret" REDIS_URL=redis://localhost:6379/1 node bot.js
> SPARK_TOKEN=0123456789abcdef PUBLIC_URL=https://abcdef.ngrok.io SECRET="not that secret" REDIS_URL=redis://localhost:6379/1 [email protected] node bot.js
```

From a windows shell, type:
Expand All @@ -56,6 +57,7 @@ From a windows shell, type:
> set SPARK_TOKEN=0123456789abcdef
> set PUBLIC_URL=https://abcdef.ngrok.io
> set SECRET=not that secret
> set [email protected]
> node bot.js
```

Expand Down
3 changes: 3 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
},
"SPARK_TOKEN": {
"description": "The API access token of your Cisco Spark bot."
},
"ALLOWED_DOMAIN": {
"description": "The domain from which messages can be received by the bot."
}
},
"addons": [
Expand Down
3 changes: 2 additions & 1 deletion bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ var controller = Botkit.sparkbot({
ciscospark_access_token: process.env.SPARK_TOKEN,
secret: process.env.SECRET, // this is a RECOMMENDED security setting that checks of incoming payloads originate from Cisco Spark
webhook_name: process.env.WEBHOOK_NAME || ('built with BotKit (' + env + ')'),
storage: storage
storage: storage,
limit_to_domain: process.env.ALLOWED_DOMAIN
});

var bot = controller.spawn({});
Expand Down

0 comments on commit 57988d7

Please sign in to comment.