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
-
Log into Bluemix or create a Bluemix account
-
Clone the watson-online-store repository locally
-
In a terminal, run:
$ git clone https://github.com/ibm/watson-online-store -
We’ll be using the file
data/workspace.jsonand the folderdata/ibm_store_html/
- Create various Bluemix services
-
Create a Watson Conversation service
-
Click on Service Credentials and save the username and password
-
Create a Watson Discovery service
-
Click on Service Credentials and save the username and password
-
Create a Cloudant NoSQL DB service
-
Click on Service Credentials and save the username, password, and url
- Configure Watson Conversation
- Launch the Watson Conversation tool
- Use the import icon button on the right
- Find the local version of
data/workspace.jsonand select Import
- Find the Workspace ID by clicking on the context menu of the new workspace, and selecting View details, save this ID
- Optionally, to view the conversation dialog select the workspace and choose the Dialog tab, here's a snippet of the dialog:
- Configure Watson Discovery
- Launch the Watson Conversation tool
- Create a new data collection
- Give the data collection a unique name
- Seed the content by selecting dialog in Add data to this collection
- Select the HTML files under
data/ibm_store_html/
- When completed, save the environment_id and configuration_id
- Configure Slack
-
Create a slack group, or use an existing one if you have sufficient authorization. Refer to [Slack's how-to] (https://get.slack.help/hc/en-us/articles/206845317-Create-a-Slack-team) on creating new groups.
-
Go to the Slack group’s application settings and add a new bot. The application settings can be accessed by navigating to
https://<slack_group>.slack.com/apps/manage. To add a bot, select the Custom Integrations menu on the left.
- Give the bot a fun name and select Add bot integration
- Once created save the API Token that is generated
- Run
/invite <botame>in a channel to invite the bot, or message it directly.
- Run the application locally
- Copy
env.sampleto.envby running:$ cp env.sample .env - Edit
.envwith the IDs we noted earlier - Run the application by running:
$ python run.py - If there are no issues the only output you'll see is: Watson Online Store bot is connected and running!
# 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
Start a conversation with your bot:
Search for an item:
Add an item to your cart:
Remove an item from your cart:












