1. Connect the SensorTag flow to the natural language understanding flow

In this section, you connect your SensorTag flow from Lab1 to the flow from Lab 3.

  1. In a browser go to your Node-RED application.
  2. In the flow editor, open the SensorTag rotation flow.
  3. Add an output link
  4. Enter a meaningful name for the link node such as SensorTag Out.
  5. Wire the output from the sensor interpreter node to the link
  6. Go to your natural language understanding flow from Lab 3.
  7. Configure the two input link nodes to accept input from the SensorTag output link node.
    You should be able to see the connection between the links.

  8. Deploy your changes.
  9. Ensure that your SensorTag is on and is broadcasting.
    You are now ready to try it out.
  10. Take your SensorTag and rotate it to generate device movement events that will be interpreted as phrases.
    The output from the Natural Language Classifier gives you the intent, and the output from the Natural Language Understanding designates the objects to act on.
  11. Drag three function nodes onto the canvas.
  12. Code the first function node to initialize data to be used downstream by entering the following code:
    global.set('received', 0);
    global.set('sentence', msg.payload);
    return msg;

  13. Code the second function node to remember the intent. Your flow now knows the intent. It needs to commit this to memory so the intent can be recalled and used downstream. Copying it from msg.payload ensures that it isn’t lost. Most node-RED nodes use msg.payload as input, some even use it for output, which means that any information on msg.payload is transient.global.set ('intent',msg.payload.top_class);
    return msg;

  14. Code the third function node to wait for both inputs:var received = global.set('received') || 0;
    If (2 === ++received) {
    return msg;
    } else {
    global.set('received', 1);

  15. Add an output link node to the output of the Check for Inputs function node and rewire the nodes together. You must break some of the existing links.
  16. Try it out with your test string. For example, use something like the Car AC.