Once prerequisites installed, configure the web application to use your craft ai project.
- Go to craft ai workbench,
- Edit the TV project,
- Click on the
craft_project.json
, notice theApplication ID
andApplication secret
values - Update variables in file
src/constants.js
:
SH_APP_ID
is theApplication ID
showedcraft_project.json
,SH_APP_SECRET
is theApplication secret
showedcraft_project.json
,SH_USER
is your github login nameSH_PROJECT
is the name of the github projet (should betv
in you've just forked the project without renaming),SH_VERSION
is the version of the github projet (should bemaster
)
- In the web application file
src/view/containers/app.jsx
, your can specify the main bt in line 34,return Runtime.createAgent( 'demo1/SayHello.bt', {} )
To install dependencies, run npm install
in a console or terminal
To launch an autoreloading server on http://localhost:4010, run npm run dev
in a console or terminal
This web application features a smartPhone (named craftPhone
) and a smartTV (named craftTV
). These devices expose some data that can be handle with craft ai.
craftTV
:- attribute
state
: possible values areon
,off
(string) - attribute
pause
: possible values aretrue
orfalse
(boolean) - attribute
volume
: possible values any integer between0
and100
craftPhone
:- attribute
state
: possible values areisCalling
,isRinging
andstandBy
(string)
To play visually with application you can:
- click on the home button of the
craftPhone
, to make calls - Click on the On/Off button of the
craftTV
remote to turn on/off the TV. - Click on the volume
+
/-
button of thecraftTV
remote to lower or increase the TV volume. - Click on the
STB
button of thecraftTV
remote to pause or not the TV.
With craft ai, we can make intelligent automation with these devices using behaviors. Basically each device exposes actions and data that craft ai can handle in the behaviors using actions nodes.
The exposed actions
are:
-
Speech
, this function makes the craft assistant in the smartPhone. Input parameter: -
message
: the text that will be displayed in the craftPhone assistant -
SetDeviceValue
, this function sets a specific value to a device. Input parameters: -
device
: the device name (craftPhone
orcraftTV
) -
attribute
: the device attribute to set (see above for the possible attributes of the related device) -
value
: the device attribute value to set (see above for the possible value of the related device attribute) -
GetDeviceValue
, this function retrieves a specific value from a device. Input parameters: -
device
: the device name (craftPhone
orcraftTV
) -
attribute
: the device attribute to set (see above for the possible attributes of the related device) attribute) Output parameters: -
name of the attribute you want to retrieve (
state
orpause
orvolume
forcraftTV
or juststate
forcraftPhone
)
There are 6 demos bt:
This demo uses behavior file demo1/SayHello.bt
(make sure this file is used as the main behavior in src/view/containers/app.jsx
line 34).
It's a simple demo that involve a simple action that helps understanding behavior update
This demo uses behavior file demo2/TurnOnTVandReceiveCall.bt
(make sure this file is used as the main behavior in src/view/containers/app.jsx
line 34).
This demo involves 2 actions and a sequence node that helps understanding how some actions can be sequentially executed.
This demo uses behavior file demo3/AdaptTvVolumeWhenCalling.bt
(make sure this file is used as the main behavior in src/view/containers/app.jsx
line 34).
This demo is the first one that brings a small intelligent automation between the craftPhone
and craftTV
. It introduces 2 new nodes, priority node and a condition node, and involves the agent knowledge using action node output parameters.
If a call occurs when the TV is on, the TV lowers automatically the volume then sets back a higher volume when the call is finished. This shows how a craft ai application can take into account a context.
This demo uses behavior file demo4/DoSomethingOnlyOnce.bt
(make sure this file is used as the main behavior in src/view/containers/app.jsx
line 34).
This demo only shows a useful pattern which allows to do something (here an action) only once. It introduces 2 new nodes,until node and a status node.
This demo uses behavior file demo5/LearnTvVolume.bt
(make sure this file is used as the main behavior in src/view/containers/app.jsx
line 34).
In this demo, the smartTV learns the tv volume the user prefers before and during a call. This shows how a craft ai application can can take into account user's preferences.
This demo uses behavior file demo5/Final.bt
(make sure this file is used as the main behavior in src/view/containers/app.jsx
line 34).
This demo shows a complete solution around the smartTV that adapts itself to the user interactions (volume and pause learning), to the smartPhone state and the home presence. Play with it, then let your imagination creates some new uses cases: ex:
- Learn tv volume or tv pause state instead of both at the same time,
- If you have web development skills, improve the web application by adding new actions (in
src/actions.js
) and new objects/compoment. (insrc/view/components
)
If you have to have a develop your craft ai skills, just follow our tutorials and read our documentation
If you have any questions, please contact our support