Respond

In this tutorial you will learn about the Respond Node, what it does and how to use and its Settings

1. What it does


As the name suggests, this node helps in passing/sending the any type of response back to the user.

Responding to the user can be happen in two ways:

  • Request User Input - No
    Here Alexa tells something to user and do not expect a reply from user.
    In this case the Output of the Respond Node is closed. So you can’t attach another node next to this.
    Note: Request User Input set to NO, Alexa Ends the Session with that user.

    When Request User Input is set to No, then all the data persisted through using Context as Conversation in Context Store will be lost.

  • Request User Input - YES
    Alexa says something to the user and expects some input/reply from the user.
    In this case the output port of the Respond node is Opened. So next time when user replies to the Alexa, the incoming request from Alexa will be automatically forwarded to next connected node.
    Note: Request User Input set to YES, Alexa do not end the session, instead continues the session with user.

Node: This node is necessary to make complete conversations with users.

2. How to use

Whether you need to send a message, SSML, card, audio or video, you must attach a Respond Node at the end of that conversation(as shown below)


3. Node Setting

  • Name
    Name for Respond Node
  • Request User Input
    • Yes
      The current user session does not end and conversation continues or state of the conversation is stored such that when next time user reply or ask something, then the conversation will be continued and the next request will be passed to next connected node.
      Its just like asking user something and expecting their reply and continue where we left off.
      when this option selected, then an output port is openend, and you can connect other nodes to continue for further communication.
    • No
      The current user session is ended and fresh conversation will be started. Its just like telling user something and do not expect their reply. It something like saying Conversation Ends here
      when this option selected, then an output port is closed, and you can not connect other nodes to continue for further communication.
  • Function

    You can execute a Javascript function block inside this Function, when this Respond Node recieves a msg object from previous connected node.

    It is necessary to return msg object at the end of Function Block, or else conversation will be halted

    You can also perform some asynchronous task in this Function Block, for that add return null at the end of Function Block and use return node.send(msg) when your asynchronous task is done.

    Examples:
    • Without Asynchronous work:
      var currentTime = Date.now();
      msg.currentTime = currentTime;
      return msg;
    • With Asynchronous work:
      doSomeAsyncWork(msg, function(result) {
          // update msg object or not and send the results
          return node.send(msg);
      });
      return null;
    Note:
    • Do not return multiple msg objects.
    • Do not change msg.govocal property other than msg.govocal.out, as msg.govocal.out is the property which contains the response for the user.
    • Do not reconstruct the msg object or else might loose some properties.

    See the online documentation for more information on writing functions.

    Logging and Error Handling

    To log any information, or report an error, the following functions are available:

    • node.log(“Log message”)
    • node.warn(“Warning”)
    • node.error(“Error”)

4. Input

Respond Node takes input from Message Node or Card Node

5. Output

Respond Node internally passes output to Router node.