Read this in other languages: 한국어.
In order to build the Node-RED flow for the CASIS satellite tracker, you will use the flow editor to add and connect nodes, and put configuration information and code in the appropriate node.
NOTE: You can move the contents of a file to your Operating System clipboard with:
pbcopy < myfile
on MacOS,
cat myfile |clip
on Windows, or
cat myfile| xclip
on Linux.
NOTE: You can find nodes in the
filter nodes
search box in the upper left of the flow editor.
NOTE: We'll add
link
nodes to allow them to fit on one screen, and to connect multiple nodes via branching. We'll add the nodes first, then connect them at the the end.
- Grab the following nodes in order, and wire them up in a row. The following 3 groups represent 3 rows:
http in
function
assistant
function
link out
link in
function
credentials
http request
json
link out
link in
function
http response
The flow should look like this:
-
Double-click the first node,
http in
and change the Method toPOST
and the URL to/botchat
-
Double-click the next
function
node, change the name toProcess chat input
and cut-n-paste the processChatInput.js code. -
Double-click the
Assistant
node, and name it 'ISS Assistant'. Add theusername
andpassword
, or the IAMapikey
, and theWorkspace ID
that you saved earlier when you created the Watson Assistant service. -
Double-click the final
function
node in the first row, name itGenerate Timestamp
, and cut-n-paste the generateTimestamp.js code. -
Start the second row by double-clicking on the first
function
node in that row and name itISS to reverse geocode function
, and paste the ISStoReverseGeocode.js code. -
Double click the
credentials
node. Click+add
under theValues
box and add the locationIQ API key to theprivate
box and change theto
box to be msg.API_key
. -
Double click the
http request
node and name itGET reverse geocode
. In the URL box paste the getReverseGeocode URL string. -
The
json
node does not need configuration. -
Begin the third row by double-clicking the
function
node and naming itAssistant output to chat
. Paste the assistantOutputToChat.js code. -
Finally, double-click the
http response
node and name itBot response
. Set the status code to200
.
- We'll build the following:
- Grab the following Nodes and connect them:
link node
switch node
in parallel:
function node
satellite node
time array
time array
function
function
from each time array:
function
function
from both functions:
satellite
link node
-
Open up the switch node, name it
Assistant Intents
, and add the propertyassistant.intents[0].intent
(aftermsg.
). We'll have a total of 6 intents, so use the+add
button to add 5 more. Name them:what
,where
,where-historical
,where-future
,mode-2d
, andmode-3d
. -
Open the top function node, name it
What is the ISS?
, and paste the whatIsTheISS.js code. -
The satellite node should already have Sat. Type
Space Stations
and SatelliteISS(ZARYA)
. -
Open the top Satellite Time Array node and configure with
+/-
10
mins, Samples20
, and NameLast 10 mins
. -
Open the second Satellite Time Array node and configure with
+/-
0
mins, Samples20
, and NameNext 10 mins
. -
Open the next function node, name it
Define Mode
and paste the defineMode.js code. -
Open the bottom function node, name it
Define Mode
and paste the defineMode.js code. Change the code from2d
to3d
. -
The 2 functions coming after the Satellite Time array should both be named
Define Text
. Paste the defineText.js code in each and change the bottom one fromLast
toNext
. -
The final Satellite node should be the same as the first, with Satellite
ISS(ZARYA)
.
-
In your Node-RED flow editor, drag-and-drop nodes for
HTTP input
,template
, andHTTP response
and wire them together. -
Double-click the first node
http in
and change the Method toGET
and the URL to/bot
. Name itChat home page
. -
Add the chat-ui.html code to the template node and name it
HTML
. -
Name the http response node
Chat http response
.
-
In the Node-RED flow editor, drag-and-drop 2
link
nodes, aninject
node, 4function
nodes, aworldmap
node, anearth
node, and aworldmap-tracks
node. -
Wire them up:
-
Double-click the
inject
node and tick the checkbox forInject once after 0.1 seconds
. -
Double-click the top function node (after the timestamp) and add the code for add map layer. Name it
add map layer
. -
Double-click the function node after the link node and add the code for ISS to Map. Name it
ISS to map
. -
Double-click the function node after
ISS to map
, and add the code for move and zoom. Name itmove and zoom
. -
Double-click the last function node, below
tracks
and aboveearth
, name itISS Path to Line
and paste the code ISSPathToLine.js. -
The
worldmap
,tracks
, andearth
nodes do not need any configuring.
The Link nodes are named for the nodes that are connected to, with either IN
or OUT
appended to indicate whether they go in to or out from that node.
You connect the link nodes by double-clicking and choosing the node they connect to . For example, we connect Generate Timestamp OUT
to Assistant Intents IN
:
- Connect
iss to reverse geocode IN
toISS Location OUT
:
- Connect
json OUT
toAssistant output to Chat IN
:
- Connect
What is ISS OUT
,ISS 2 OUT
,Define Mode 2d OUT
, andDefine Mode 3d OUT
toAssistant output to Chat IN
:
- Connect
ISS Location OUT
to bothss to reverse geocode IN
andISS to Map IN
:
- Connect
ISS 2 OUT
toISS to Map IN
andISS Path to Line IN
(It's already connected toAssistant output to Chat IN
):
Click Deploy
Use the running app by going to <Node-RED_URL>/bot