https://github.com/kostickm/watsonbot
Watson Conversation Slack Bot
https://github.com/kostickm/watsonbot
slack slackbot watson watson-conversation
Last synced: about 2 months ago
JSON representation
Watson Conversation Slack Bot
- Host: GitHub
- URL: https://github.com/kostickm/watsonbot
- Owner: kostickm
- License: apache-2.0
- Created: 2017-06-16T21:41:28.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-10T13:51:50.000Z (almost 9 years ago)
- Last Synced: 2025-07-01T14:43:18.398Z (12 months ago)
- Topics: slack, slackbot, watson, watson-conversation
- Language: Python
- Size: 1.53 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# watsonbot
**Watson Conversation Slack Bot**
Get started with the [Watson Conversation Service](https://console.bluemix.net/catalog/services/conversation) by creating your very own Slack Chat Bot. This demo will walk you through all of the necessary steps to configure your Watson Conversation service, set up your Slack bot, and deploy your application to Bluemix. You will be chatting with Watson in no time!
## Prerequistes
### Python
* [Python 2.7.x](https://www.python.org/downloads/)
### Slack
* [Slack](https://slack.com)
* [Slack API](https://api.slack.com/)
### Bluemix
* [Bluemix Account](https://console.bluemix.net/)
* [Bluemix CLI](https://clis.ng.bluemix.net/ui/home.html)
### Git
* [Github Account](https://github.com)
* [Git](https://git-scm.com/downloads)
## Steps
### Set up the Watson Conversation Service
1. See the [instructions](conversation/README.md) for setting up and configuring your [Watson Conversation Service](https://console.bluemix.net/catalog/services/conversation).
### Clone project and update for your Slack bot
1. Git clone this sample project
`$ git clone git@github.com:kostickm/watsonbot.git`
2. Change to your the newly cloned repo
`$ cd watsonbot/`
3. Create a new Slack [bot](https://api.slack.com/bot-users), you will be assigned a Slack API Token
4. Export your assigned Slack API Token
```
# Windows
$ set SLACK_BOT_TOKEN=
# macOS/Linux
$ export SLACK_BOT_TOKEN=''
```
5. Install the `slackclient` python package
```
$ pip install slackclient
```
6. Run the `print_bot_id.py` script
```
$ python print_bot_id.py
Bot ID for 'watsonbot' is
```
7. Save both of these credentials for use later in this tutorial
8. Copy the `env.sample` file to a new file named `.env`
```
# Windows
$ copy env.sample .env
# macOS/Linux
$ cp env.sample .env
```
9. Open and update the `.env`. file with your Slack credentials
```
# Slack
SLACK_BOT_TOKEN=
SLACK_BOT_ID=
```
10. Open and update the `.env`. file with your Watson Conversation credentials
```
# Watson conversation
CONVERSATION_USERNAME=
CONVERSATION_PASSWORD=
WORKSPACE_ID=
```
11. Open the `manifest.yml` file and replace `` with the unique name of your app
```
---
applications:
- name:
domain: mybluemix.net
memory: 128M
health-check-type: none
buildpack: https://github.com/cloudfoundry/buildpack-python.git
```
12. Open the `setup.py` file and replace ``with the unique name of your app
```
# Always prefer setuptools over distutils
from setuptools import setup
long_description = ('This is a sample Watson Conversation Slack chat bot.')
setup(
name='',
version='1.0.0',
description='Watson Slack Chat Bot',
long_description=long_description,
license='Apache-2.0'
)
```
13. *Optional: Run locally to test*
**Note: Make sure to set/export all environment variables located in the `.env` file before running locally. Also `pip` install all python packages listed in the `requirements.txt` file.**
`$ python watsonbot.py`
Chat with your `watsonbot` by sending a Slack message starting with `@watsonbot`.
### Deploy to Bluemix
You are now ready to deploy your application to Bluemix.
*Note: You may also use the shorthand command `bx` instead of `bluemix`.*
1. Log into Bluemix CLI using your Bluemix credentials
`$ bluemix api https://api.ng.bluemix.net`
`$ bluemix login`
2. From your local app directory deploy your app to Bluemix
`$ bluemix app push`
### Chat with Watson
1. Check that your app is running in Bluemix

2. Test out your deployed app in Slack. Chat with your `watsonbot` by sending a Slack message starting with `@watsonbot`.
## Next Steps
* Check out the other Watson Python SDK [examples](https://github.com/watson-developer-cloud/python-sdk/tree/master/examples)
* Add in the Watson Language Translation service
* Add in the Watson Tone Analyzer service
* Incorporate an API (Weather, Calendar, Github, etc.)
* Have Watson tell you a joke