A Chat Interface for sending commands to your home devices via the Watson Conversation API
Before you try out this application, you will need to setup your Watson conversation service workspace and a PubNub BLOCK.
PubNub BLOCK acts as the virtual agent and the code that runs within the BLOCK is here. Refer to this README file for setting up and executing your BLOCK.
Follow the steps below to setup the conversation workspace and dialog.
- In the step description for conversation service, the word block refers to the dialog creation node.
This is not to be confused with the word BLOCK (in all caps) which refers to the PubNub microservice.
- Once the conversation service is created, you need to copy some credentials from your conversation workspace
to the BLOCK code. This is required for the virtual agent to correctly invoke the conversation service and
decipher the commands. There are three parameters to be copied
a. Pay attention to the step 4.2 where you have to copy the conversation workspace credentials into your BLOCK code.
b. Refer to the "Conversation API Credentials" section below to copy your conversation workspace's username and password
to the BLOCK code.
Log on to Bluemix with your IBM ID and go to catalog, and select "Conversation" under Watson services.
Enter the service name and make the connect to field "leave unbound" and scroll down and select the Free pricing plan, then click on Create button.
Open the "Home Automation" service then click on the "Launch tool" button.
Click on the create button, then enter the name for the workspace
Once the workspace is created.Click the menu icon in the upper-right corner of the tile for the created workspace, and then select View details.
Then copy the workspace id and then paste in the main.js code here in line number 24 .
Replace the highlighted id with your workspace.
Open the created workspace, Click on the Intents and start entering the intents.
You can enter the intents like the following picture (following picture shown for the intent "turnon")
You can follow the same procedure for the remaining intents.
Open Entities tab, and click on "Create new" button then start entering the entities.
You have created an Entity.
Open the Dialog tab and click on the create button.
Start writing the initial Node
Give a name to that node for example start Node like shown in the image.
Select "conversation_start(create new condition)" in the Trigger field, and In the response write the introduction message as shown in the image.
Your first node is created.
To create another node click on the plus symbol down the first node.
Write the Name for the node in the name field.
In the Trigger field write "#turnon(create new condition)", then close the node.
Click on the plus next to the node. Write the name in the name field as shown and write the "@room(create new condition)" condition in the Trigger field,
Write "Turning ON @room" under the responses.
Then select the "Jumpto" icon on "Turn on intent node"
and then click on "Room_on" node, then select "Go to condition".
Your "turnon" node is created
In the similar way you can create blocks for the "turnoff" and "is" intents by repeating the steps from 8.2 to 8.4.
Anything else block is for any other irrelevant messages.Enter the name in the name field,condition will be predefined in the trigger field or else write "anything_else(create new condition)" in the trigger field, and the in the response field write "sorry i am not trained to anwer this question" and "Command not identified".
Here you can see the response variations as sequential and random.You can select any of the option.
1.sequential - Will give response in a sequence manner
2.random - Will give response in random
Open the block code here
Open the conversation api service and goto the "Service Credentials".
Replace the username in line number 9 and password line number 10 with the credentials you got.