In this developer journey we will create a Watson Conversation based chatbot that allows a user to: 1) find items to purchase using Watson Discovery, and 2) add and remove items from their cart by updating a Cloudant NoSQL Database.
When the reader has completed this journey, they will understand how to:
- Create a chatbot dialog with Watson Conversation
- Dynamically store and update a Cloudant NoSQL database based on chatbot results
- Seed data into Watson Discovery and leverage its natural language capabilities
- Manage and customize a Slack group to add a chatbot
- Bluemix Watson Conversation
- Bluemix Watson Discovery
- Bluemix Cloudant NoSQL DB
- Slack
- Python
Perform steps 1-6 or choose the Deploy to Bluemix button and jump to step 5.
- Clone the repo
- Create Bluemix services
- Configure Watson Conversation
- Configure Watson Discovery
- Configure Slack
- Run the application
Clone the watson-online-store
locally. In a terminal, run:
$ git clone https://github.com/ibm/watson-online-store
We’ll be using the file data/workspace.json
and the folder data/ibm_store_html/
Create the following services:
- Watson Conversation
- Watson Discovery
- Cloudant NoSQL DB
Launch the Watson Conversation tool. Use the import icon button on the right
Find the local version of data/workspace.json
and select Import. Find the
Workspace ID by clicking on the context menu of the new workspace, and selecting
View details, save this ID for later.
Optionally, to view the conversation dialog select the workspace and choose the Dialog tab, here's a snippet of the dialog:
Launch the Watson Conversation tool. Create a new data collection and give the data collection a unique name.
Seed the content by selecting Add data to this collection in the dialog,
choose the HTML files under data/ibm_store_html/
. When completed, save the
environment_id and configuration_id.
Create a slack group or use an existing one if you
have sufficient authorization. (Refer to Slack's how-to
on creating new groups.) To add a new bot, go to the Slack group’s application settings
by navigating to https://<slack_group>.slack.com/apps/manage
and selecting the
Custom Integrations menu on the left.
Give the bot a fun name. Once created save the API Token that is generated
Run /invite <botame>
in a channel to invite the bot, or message it directly.
Copy the env.sample
to .env
, edit it with the necessary IDs and run the application.
$ cp env.sample .env
$ # edit .env
$ python run.py
Start a conversation with your bot:
Add an item to your cart:
- Sample .env to use:
# Watson conversation
CONVERSATION_USERNAME=e6ca86f1-302a-4803-b408-7949c7abaa1a
CONVERSATION_PASSWORD=PQ6fjelpPyPx
WORKSPACE_ID=19849a01-19e4-47ad-bg3f-6cafe376aeed
# Cloudant DB
CLOUDANT_USERNAME="715ac810-921f-4290-92fc-061642ee4b3a-bluemix"
CLOUDANT_PASSWORD="25fdf0c1411d2584b693c9f8aeda9b260b23656ec32c0da0839ed1cf7c2bd594"
CLOUDANT_DB_NAME="cloudant_online_store"
CLOUDANT_URL="https://715ac810-921f-4290-92fc-061642ee4b3a-bluemix.cloudant.com"
# Watson Discovery
DISCOVERY_USERNAME=03c25743-4728-448e-b3ed-3b198e6edd65
DISCOVERY_PASSWORD=4LDhpX27q7QZ
DISCOVERY_ENVIRONMENT_ID=a2e0e223-aec9-458e-95b5-d4d618e1ae6d
DISCOVERY_COLLECTION_ID=d06e9ddf-7c27-4dce-b80f-dca8768a72d8
# Slack
SLACK_BOT_TOKEN=xoxb-cbe837f60865-bjgftpFM6tnJXTvZzIw8Ihui
SLACK_BOT_NAME=hal