Home Automation Virtual Agent
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.
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.
Watson Conversation Service
Step 1 :
Log on to Bluemix with your IBM ID and go to catalog, and select "Conversation" under Watson services.
Step 2 :
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.
Step 3 :
Open the "Home Automation" service then click on the "Launch tool" button.
Step 4 :
Click on the create button, then enter the name for the workspace
Step 4.1 :
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.
Step 4.2 :
Then copy the workspace id and then paste in the main.js code here in line number 24 .
Step 4.3 :
Replace the highlighted id with your workspace.
Step 5 :
Open the created workspace, Click on the Intents and start entering the intents.
Step 5.1 :
You can enter the intents like the following picture (following picture shown for the intent "turnon")
Step 5.2 :
You can follow the same procedure for the remaining intents.
Step 6 :
Open Entities tab, and click on "Create new" button then start entering the entities.
You have created an Entity.
Step 7 :
Open the Dialog tab and click on the create button.
Step 7.1 :
Start writing the initial Node
Step 7.2 :
Give a name to that node for example start Node like shown in the image.
Step 7.3 :
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.
Step 8 :
To create another node click on the plus symbol down the first node.
Step 8.1 :
Write the Name for the node in the name field.
Step 8.2 :
In the Trigger field write "#turnon(create new condition)", then close the node.
Step 8.3 :
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.
Step 8.4 :
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
Step 9 :
In the similar way you can create blocks for the "turnoff" and "is" intents by repeating the steps from 8.2 to 8.4.
Step 10 :
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
Conversation API Credentials
Step 1 :
Open the block code here
Step 2 :
Open the conversation api service and goto the "Service Credentials".
Step 3 :
Replace the username in line number 9 and password line number 10 with the credentials you got.