Skip to content

Commit a2236ba

Browse files
authored
Merge branch 'master' into unit
2 parents aec1812 + 2700aad commit a2236ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+255
-86
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ examples/db_team_bot/
1010
*/.DS_Store
1111
.env
1212
.idea
13-
.vscode/settings.json
13+
.vscode
1414
coverage

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs/provisioning/IMG

.vscode/launch.json

-46
This file was deleted.

changelog.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Adds [ConsoleBot](lib/ConsoleBot.js) for creating bots that work on the command
206206

207207
Adds a new [Middleware Readme](readme-middlewares.md) for documenting the existing middleware modules
208208

209-
Adds an example for using quick replies in the [Facebook Example Bot](facebook_bot.js)
209+
Adds an example for using quick replies in the [Facebook Example Bot](examples/facebook_bot.js)
210210

211211
Adds additional fields to Facebook messages to specify if they are `facebook_postback`s or normal messages.
212212

@@ -290,7 +290,7 @@ Make the oauth identity available to the user of the OAuth endpoint via `req.ide
290290

291291
Fix issue where single team apps had a hard time receiving slash command events without funky workaround. (closes [Issue #108](https://github.com/howdyai/botkit/issues/108))
292292

293-
Add [team_slashcommand.js](/examples/team_slashcommand.js) and [team_outgoingwebhook.js](/examples/team_outgoingwebhook.js) to the examples folder.
293+
Add [team_slashcommand.js](/examples/slack/team_slashcommand.js) and [team_outgoingwebhook.js](/examples/slack/team_outgoingwebhook.js) to the examples folder.
294294

295295

296296

docs/examples.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33

44
These examples are included in the Botkit [Github repo](https://github.com/howdyai/botkit).
55

6-
[slack_bot.js](https://github.com/howdyai/botkit/blob/master/slack_bot.js) An example bot that can be connected to your team. Useful as a basis for creating your first bot!
6+
[slack_bot.js](https://github.com/howdyai/botkit/blob/master/examples/slack_bot.js) An example bot that can be connected to your team. Useful as a basis for creating your first bot!
77

8-
[spark_bot.js](https://github.com/howdyai/botkit/blob/master/spark_bot.js) An example bot that can be connected to Cisco Spark. Useful as a basis for creating your first bot!
8+
[spark_bot.js](https://github.com/howdyai/botkit/blob/master/examples/spark_bot.js) An example bot that can be connected to Cisco Spark. Useful as a basis for creating your first bot!
99

10-
[facebook_bot.js](https://github.com/howdyai/botkit/blob/master/facebook_bot.js) An example bot that can be connected to your Facebook page. Useful as a basis for creating your first bot!
10+
[facebook_bot.js](https://github.com/howdyai/botkit/blob/master/examples/facebook_bot.js) An example bot that can be connected to your Facebook page. Useful as a basis for creating your first bot!
1111

12-
[twilio_ipm_bot.js](https://github.com/howdyai/botkit/blob/master/twilio_ipm_bot.js) An example bot that can be connected to your Twilio IP Messaging client. Useful as a basis for creating your first bot!
12+
[twilio_ipm_bot.js](https://github.com/howdyai/botkit/blob/master/examples/twilio_ipm_bot.js) An example bot that can be connected to your Twilio IP Messaging client. Useful as a basis for creating your first bot!
1313

14-
[botframework_bot.js](https://github.com/howdyai/botkit/blob/master/botframework_bot.js) An example bot that can be connected to the Microsoft Bot Framework network. Useful as a basis for creating your first bot!
14+
[botframework_bot.js](https://github.com/howdyai/botkit/blob/master/examples/botframework_bot.js) An example bot that can be connected to the Microsoft Bot Framework network. Useful as a basis for creating your first bot!
1515

16-
[examples/demo_bot.js](https://github.com/howdyai/botkit/blob/master/examples/demo_bot.js) another example bot that uses different ways to send and receive messages.
16+
[examples/demo_bot.js](https://github.com/howdyai/botkit/blob/master/examples/slack/demo_bot.js) another example bot that uses different ways to send and receive messages.
1717

18-
[examples/team_outgoingwebhook.js](https://github.com/howdyai/botkit/blob/master/examples/team_outgoingwebhook.js) an example of a Botkit app that receives and responds to outgoing webhooks from a single team.
18+
[examples/team_outgoingwebhook.js](https://github.com/howdyai/botkit/blob/master/examples/slack/team_outgoingwebhook.js) an example of a Botkit app that receives and responds to outgoing webhooks from a single team.
1919

20-
[examples/team_slashcommand.js](https://github.com/howdyai/botkit/blob/master/examples/team_slashcommand.js) an example of a Botkit app that receives slash commands from a single team.
20+
[examples/team_slashcommand.js](https://github.com/howdyai/botkit/blob/master/examples/slack/team_slashcommand.js) an example of a Botkit app that receives slash commands from a single team.
2121

22-
[examples/slackbutton_bot.js](https://github.com/howdyai/botkit/blob/master/examples/slackbutton_bot.js) an example of using the Slack Button to offer a bot integration.
22+
[examples/slackbutton_bot.js](https://github.com/howdyai/botkit/blob/master/examples/slack/slackbutton_bot.js) an example of using the Slack Button to offer a bot integration.
2323

24-
[examples/slackbutton_incomingwebhooks.js](https://github.com/howdyai/botkit/blob/master/examples/slackbutton_incomingwebhooks.js) an example of using the Slack Button to offer an incoming webhook integration. This example also includes a simple form which allows you to broadcast a message to any team who adds the integration.
24+
[examples/slackbutton_incomingwebhooks.js](https://github.com/howdyai/botkit/blob/master/examples/slack/slackbutton_incomingwebhooks.js) an example of using the Slack Button to offer an incoming webhook integration. This example also includes a simple form which allows you to broadcast a message to any team who adds the integration.
2525

26-
[example/sentiment_analysis.js](https://github.com/howdyai/botkit/blob/master/examples/sentiment_analysis.js) a simple example of a chatbot using sentiment analysis. Keeps a running score of each user based on positive and negative keywords. Messages and thresholds can be configured.
26+
[example/sentiment_analysis.js](https://github.com/howdyai/botkit/blob/master/examples/slack/sentiment_analysis.js) a simple example of a chatbot using sentiment analysis. Keeps a running score of each user based on positive and negative keywords. Messages and thresholds can be configured.
44.1 KB
Loading

docs/provisioning/IMG/botkit_icon.png

48.9 KB
Loading

docs/provisioning/IMG/cisco_add.png

55.6 KB
Loading

docs/provisioning/IMG/fb_app_perm.png

83.8 KB
Loading

docs/provisioning/IMG/fb_mess.png

12.4 KB
Loading

docs/provisioning/IMG/fb_new.png

36.8 KB
Loading

docs/provisioning/IMG/fb_tokengen.png

35.1 KB
Loading

docs/provisioning/IMG/fb_webhooks.png

45 KB
Loading
41.6 KB
Loading
60.4 KB
Loading

docs/provisioning/IMG/slack-im.png

63.9 KB
Loading

docs/provisioning/IMG/slack-new.png

48 KB
Loading
53.3 KB
Loading
37.6 KB
Loading

docs/provisioning/IMG/slack_oauth.png

42.5 KB
Loading

docs/provisioning/cisco-spark.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Configure Botkit and Cisco Spark
2+
3+
Setting up a bot for Cisco Spark is one of the easiest experiences for bot developers! Follow these steps carefully to configure your bot.
4+
5+
### 1. Install Botkit
6+
7+
The easiest path to creating a new bot for Cisco Spark is through Botkit Studio. [Sign up for an account here](https://studio.botkit.ai/signup/). This method will provide a guided path to hosting, along with other useful tools for creating and managing your bot.
8+
9+
For advanced users looking to run their own code, you will need to [install Botkit](../readme-ciscospark.md#getting-started) and run it before your bot can be configured with Cisco Spark.
10+
11+
### 2. Create a new bot in the Cisco Developer portal
12+
13+
Follow the instructions to create a new bot in the [Cisco Spark Developer Portal](https://developer.ciscospark.com/add-bot.html).
14+
15+
![Add a bot](IMG/cisco_add.png)
16+
17+
Take note of the bot username, you'll need it later.
18+
19+
**Note about your icon**: Cisco requires you host an avatar for your bot before you can create it in their portal. This bot needs to be a 512x512px image icon hosted anywhere on the web. This can be changed later.
20+
21+
You can copy and paste this URL for a Botkit icon you can use right away: `https://raw.githubusercontent.com/howdyai/botkit-starter-ciscospark/master/public/default_icon.png`
22+
23+
### 3. Copy your access token
24+
25+
Cisco will provide you an `access token` that is specific to your bot. Write this down, you won't be able to see this later (but you will be able revoke it and create a new one).
26+
27+
### 4. Run your bot with variables set
28+
29+
[Follow these instructions](../readme-ciscospark.md#getting-started) to run your bot locally, or by using a third-party service such as [Glitch](https://glitch.com) or [Heroku](https://heroku.com).
30+
31+
You will need the following environment variables when running your bot:
32+
33+
* `access_token` = Your token from Cisco Spark (**required**)
34+
* `secret` = User-defined string to validate payloads (**required**)
35+
* `public_address`= URL of your bot server (**required**)
36+
* `studio_token`= [Botkit Studio](https://studio.botkit.ai) API token (optional)
37+
38+
You should now be able to search your Cisco Spark team for the bot username you defined, and add it to your team!
39+
40+
### Additional resources
41+
42+
Read more about making bots for this platform in the [Cisco Developer Portal](https://developer.ciscospark.com/bots.html).
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Configure Botkit and Facebook Messenger
2+
3+
Facebook is a constantly evolving platform, nominally you can find everything you [need to create a bot](https://developers.facebook.com/docs/messenger-platform/guides/quick-start) on their platform page, but that information is subject to change.
4+
5+
The easiest path to creating a new bot for Facebook Messenger is through Botkit Studio. [Sign up for an account here](https://studio.botkit.ai/signup/). This method will provide a guided path to hosting, along with other useful tools for creating and managing your bot.
6+
7+
For advanced users looking to run their own code, you will need to [install Botkit](https://github.com/howdyai/botkit-starter-facebook) and run it before your bot can be configured with Messenger.
8+
9+
### 1. [Install Botkit](https://github.com/howdyai/botkit/blob/master/readme.md#start-with-botkit-studio)
10+
11+
Once installed, you will need to do steps 2-4, and steps 5 in parallel. It helps to have your development enviroment and the Facebook for Developers page open at the same time.
12+
13+
### 2. Create a Facebook App for Web
14+
15+
Visit [Facebook for Developers page](https://developers.facebook.com/tools-and-support/) and create a new app.
16+
17+
![Create your APP ID](IMG/fb_new.png)
18+
19+
* Select a Messenger application
20+
21+
![Create your app](IMG/fb_mess.png)
22+
23+
### 3. Get a Page Access Token for your app
24+
Scroll down to `Token Generation`
25+
26+
![page access token](IMG/fb_tokengen.png)
27+
28+
If you have not yet created your page yet, you can go ahead and do this now, or associate this new bot with an existing page.
29+
30+
Copy this `Page Access Token`, you'll need it when running your bot.
31+
32+
### 4. Setup webhooks
33+
Click `Setup Webhooks` to link this application to your Botkit instance.
34+
35+
![page access token](IMG/fb_webhooks.png)
36+
37+
The callback url will be `https://YOURURL/facebook/receive`. This URL must be publically available, and SSL-secured. More information on this can be found in the next step.
38+
39+
You will also need to define a `Verify Token` for your page subscription. This is a user-defined string that you will keep secret and pass in with your environment variables.
40+
41+
### 5. Run your application
42+
43+
Run your application with your environment variables set:
44+
45+
* `page_token` - Your Page Access Token (**required**)
46+
* `verify_token` - Your Verify Token (**required**)
47+
* `studio_token` - Your [Botkit Studio](https://studio.botkit.ai/signup) Token (optional)
48+
49+
If your application has been configured correctly, you will be able to talk to your bot through the page you specified in Step 3. Congratulations!
50+
51+
### Additional resources
52+
* [Botkit Facebook readme](https://github.com/howdyai/botkit/blob/master/docs/readme-facebook.md)
53+
* [Botkit Facebook Starter Kit](https://github.com/howdyai/botkit-starter-facebook)
54+
* [Messenger Platform Documentation](https://developers.facebook.com/products/messenger/)
55+
* [Sign up for Botkit Studio](https://studio.botkit.ai/)

docs/provisioning/readme.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Provisioning Botkit
2+
As Botkit adds more platforms, it becomes increasingly difficult to keep track of all the methods for provisioning your bot on the various platforms we support.
3+
4+
To help Botkit developers, we are pulling out detailed provisioning documents for each platform and keeping them in this directory. Our hope is that this will make our docs more flexible to platform changes, and clearly show the fastest way to stand up your bot!
5+
6+
## Platforms
7+
8+
#### [Slack (Events API)](slack-events-api.md)
9+
10+
#### [Facebook Messenger](facebook_messenger.md)
11+
12+
#### [Cisco Spark](cisco-spark.md)
13+
14+
## Documentation
15+
16+
* [Get Started](../../readme.md)
17+
* [Botkit Studio API](../readme-studio.md)
18+
* [Function index](../readme.md#developing-with-botkit)
19+
* [Extending Botkit with Plugins and Middleware](../middleware.md)
20+
* [List of current plugins](../readme-middlewares.md)
21+
* [Storing Information](../storage.md)
22+
* [Logging](../logging.md)
23+
* Platforms
24+
* [Slack](../readme-slack.md)
25+
* [Cisco Spark](../readme-ciscospark.md)
26+
* [Facebook Messenger](../readme-facebook.md)
27+
* [Twilio IPM](https://../readme-twilioipm.md)
28+
* [Microsoft Bot Framework](../readme-botframework.md)
29+
* Contributing to Botkit
30+
* [Contributing to Botkit Core](../../CONTRIBUTING.md)
31+
* [Building Middleware/plugins](../howto/build_middleware.md)
32+
* [Building platform connectors](../howto/build_connector.md)

docs/provisioning/slack-events-api.md

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Configure Botkit and the Slack Events API
2+
3+
Building a bot with Botkit and the Slack Events API gives you access to all of the best tools and options available to create a feature-rich bot for Slack.
4+
5+
In order to get everything set up, you will need to configure a new Slack App inside the [Slack Developer Portal](http://api.slack.com/apps), and at the same time, configure a [Botkit-powered bot](http://botkit.ai). It only takes a few moments, but there are a bunch of steps, so follow these instructions carefully.
6+
7+
This feature is still in very active development at Slack, and these steps are subject to change.
8+
9+
## 1. Create a new Slack App
10+
11+
Go to [http://api.slack.com/apps](http://api.slack.com/apps) and create a new application record.
12+
13+
![Create your app](IMG/slack-new.png)
14+
15+
You will receive a `clientId` and a `clientSecret`. You need these values - copy them into a temporary text file for use in the following steps.
16+
17+
![Create your app](IMG/slack_client_secret.png)
18+
19+
## 2. Turn on your Botkit app
20+
21+
Botkit Studio provides the easiest path to creating a new bot for Slack. This method will provide a guided path to hosting, along with other useful tools for creating and managing your bot. If you're already using [Botkit Studio](https://studio.botkit.ai/), this is happening in the background!
22+
23+
For advanced users looking to run their own code, you will need to [install Botkit](https://github.com/howdyai/botkit-starter-slack) and run it before your bot can be configured with Slack.
24+
25+
Once you've collected your `clientId` and `clientSecret` tokens from Slack, you can start your Botkit app. You will need to have a bot service online and reachable over the web to complete the following steps and finish setting up your bot.
26+
27+
## 3. Configure OAuth
28+
29+
Botkit and Slack use the OAuth authentication system to grant bots access to connect to, read from, and send messages to Slack teams.
30+
31+
![Setup Oauth](IMG/slack_oauth.png)
32+
33+
Click on the "OAuth & Permissions" tab in your Slack's app setting, and under Redirect URLs, add: `https://my-bot-url/oauth`, and save your progress.
34+
35+
## 4. Add a Bot User
36+
37+
Click on the "Bot Users" tab and specify a name for your bot. This is the name that will be used by default when your application creates a new bot on a user's team.
38+
39+
![Setup Oauth](IMG/slack-botuser.png)
40+
41+
In addition to a name, enable the option for "Always Show My Bot Online." This will ensure your Bot appears online to your team.
42+
43+
## 5. Set up Interactive Messages
44+
45+
"Interactive messages" is Slack's fancy way of saying "buttons." In order to enable buttons, under Request URL, add `https://YOURURL/slack/receive`, then click save.
46+
47+
![Setup Interactive images](IMG/slack-im.png)
48+
49+
## 6. Set up Event Subscriptions
50+
51+
To start receiving messages, you will need to enable Event Subscriptions. Finally, scroll to the top of the page and switch "Enable Events" to "on".
52+
53+
Next you will need to add your Request URL, like this: `https://YOURURL/slack/receive`. When you finish typing, Slack will verify that this endpoint is properly configured. You must be running your Botkit application at the URL specified for this to work.
54+
55+
![Verify your endpoints](IMG/Slack-eventsenable.png)
56+
57+
Once verified, click "Add Bot User Event", and using the dropdown that appears, select all of the `message.*` events:
58+
59+
* `message.channels`
60+
* `message.groups`
61+
* `message.ims`
62+
* `message.mpim`
63+
64+
This configuration tells Slack to send your bot all messages that are sent in any channel or group in which your bot is present. Add other events as needed.
65+
66+
![Add some subscriptions](IMG/slack_botevents.png)
67+
68+
Your bot is now ready to receive messages!
69+
70+
*Problems?* : If you do not see `Bot User` here, it is likely that you forgot to add a Bot User back in Step 4. Go and fix that now, and come back to Step 6 to continue.
71+
72+
*Note*: If you intend on submitting to the App Directory, be sure to have a good reason to request more widely ranging events as your app can be rejected for excessively wide permissions.
73+
74+
## 7. Add your bot to your Slack team
75+
76+
Now that your bot is configured, and your appliacation is up and running, you can login and add your bot. Visit `https://MYURL/`, and you will be automatically directed to Slack's login page. Login and choose a team. You'll get one more confirmation before being redirected back to your app.
77+
78+
Meanwhile, your bot should appear inside your Slack team. You should receive a friendly welcome message to indicates your bot is now online and working!
79+
80+
## Additional resources
81+
* [Botkit Slack readme](../readme-slack.md)
82+
* [Slack's official documention for Events API](https://api.slack.com/events-api)
83+
* [Sign up for Botkit Studio](https://studio.botkit.ai/signup)

docs/readme-botframework.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Table of Contents
3434
4) Run the example bot using the App ID & Password you were assigned. If you are _not_ running your bot at a public, SSL-enabled internet address, use the --lt option and update your bots endpoint in the developer portal to use the URL assigned to your bot.
3535

3636
```
37-
app_id=<MY_APP_ID> app_password=<MY_APP_PASSWORD> node botframework_bot.js [--lt [--ltsubdomain CUSTOM_SUBDOMAIN]]
37+
app_id=<MY_APP_ID> app_password=<MY_APP_PASSWORD> node examples/botframework_bot.js [--lt [--ltsubdomain CUSTOM_SUBDOMAIN]]
3838
```
3939

4040
5) Your bot should be online! Within Skype, find the bot in your contacts list, and send it a message.

docs/readme-ciscospark.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ngrok http 3000
3535
4) Run your bot application using the access token you received, the base url of your bot application, and a secret which is used to validate the origin of incoming webhooks:
3636

3737
```
38-
access_token=<MY ACCESS TOKEN> public_address=<https://my_bot_url> secret=<my_secret_phrase> node spark_bot.js
38+
access_token=<MY ACCESS TOKEN> public_address=<https://my_bot_url> secret=<my_secret_phrase> node examples/spark_bot.js
3939
```
4040

4141
5) Your bot should now come online and respond to requests! Find it in Cisco Spark by searching for it's name.

0 commit comments

Comments
 (0)