UNPKG

node-red-contrib-googlehome-actions-v2-piyanggoon

Version:
109 lines (104 loc) 4.53 kB
<script type="text/javascript"> RED.nodes.registerType('googlehome-send',{ category: 'Google Assistant', defaults: { name: {value: ""}, close_conversation: {value: false}, continue_after: {value: false}, close_message: {value: ""}, }, paletteLabel: "Send", icon: 'googlehome-send.png', outputs: 1, inputs: 1, label: function() { return (this.name !== "" ? "Send (" + this.name + ")" : "Google Home Send"); }, oneditprepare: function(){ if(!this.close_conversation){ $(".form-row-close-message").hide(); } if(this.continue_after){ $(".form-row-close").hide(); } $("#node-input-close_conversation").on("click", function(){ $(".form-row-close-message").hide(); if($("#node-input-close_conversation")[0].checked == true){ $(".form-row-close-message").show(); } }); $("#node-input-continue_after").on("click", function(){ $(".form-row-close").hide(); $(".form-row-close-message").hide(); if($("#node-input-continue_after")[0].checked == false){ $(".form-row-close").show(); if($("#node-input-close_conversation")[0].checked == true){ $(".form-row-close-message").show(); } } }); //TODO: Hide close message if not closing the conversation } }); </script> <script type="text/x-red" data-template-name="googlehome-send"> <div class="form-row"> <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-continue_after"><i class="fa fa-tag"></i> Continue</label> <input type="checkbox" id="node-input-continue_after" placeholder="Continue" style="width: auto; margin: 0;"> </div> <div class="form-row form-row-close"> <label for="node-input-close_conversation"><i class="fa fa-tag"></i> Close</label> <input type="checkbox" id="node-input-close_conversation" placeholder="Close" style="width: auto; margin: 0;"> </div> <div class="form-row form-row-close form-row-close-message"> <label for="node-input-close_message"><i class="fa fa-tag"></i> Close Message</label> <input type="text" id="node-input-close_message" placeholder="Close Message"> </div> </script> <script type="text/x-red" data-help-name="googlehome-send"> <p>This node finish the conversation sending all answers back to Google Assistant.</p> <p> If the message is only a part of the final message you can use <code>continue</code> to pospone to the next Send Node. If you set the <code>continue</code> option you must have another send node after this one without the <code>continue</code> option set. </p> <p>The <code>close</code> and <code>close message</code> property in the node editor tells to close or not the conversation. Close the conversation stop the app running on the device.</p> <h3>Input</h3> <ol class="node-ports"> <li>Answer <dl class="message-properties"> <dl class="message-properties"> <dt>msg.gh_messages <span class="property-type">array</span></dt> <dd>An array of messages objects that will be sent to google assistant as an answer.</dd> </dl> </li> </ol> <h3>Details</h3> <p>A send node should be at the end of the process. It will get all messages and send back to google.</p> <p>To change the response that will be sent, change the <code>msg.gh_messages</code> before this node.</p> <p><code>msg.gh_messages</code> array items formats:</p> <p></p> <p>Simple Response</p> <p><code> { "type": "SimpleResponse", "message": "Your Message here" } </code></p> <p>LinkOutSuggestion</p> <p><code> { "type": "link", "message": { "url": "https://example.com" } } </code></p> <p></p> <p>Another responses are supported, you can look at source code or wait me to document them.</p> <p>Carousel, Image, Table, LinkOutSuggestion</p> </script>