UNPKG

node-red-contrib-viseo-aws

Version:

VISEO Bot Maker - AWS Lex and Rekognition

208 lines (180 loc) 9.62 kB
<script type="text/javascript"> RED.nodes.registerType('aws-lex', { category: '💬_language', color: '#ffe0b3', defaults: { name: { value: undefined }, token: { value: undefined, type: 'aws-config', required: false }, botname: { value: undefined }, botalias: { value: undefined }, action: { value: "postText" }, input: { value: "payload" }, inputType: { value: "msg" }, output: { value: "payload" }, content: { value: undefined }, contentType: { value: "text/plain; charset=utf-8"}, userid: { value: "user.id" }, useridType: { value: "msg" }, sessionA: { value: undefined }, sessionAType: { value: "str" }, requestA: { value: undefined }, requestAType: { value: "str" } }, inputs: 1, outputs: 1, icon: 'aws.png', align: 'left', paletteLabel: 'Lex', label: function () { return this.name || 'Lex' }, oneditprepare: function() { // TypedInput for Content-Types var ct_PCM1 = { value:"audio/l16; rate=16000; channels=1", label:"Audio/PCM-L16", hasValue:false }; var ct_PCM2 = { value:"audio/x-l16; sample-rate=16000; channel-count=1", label:"Audio/PCM-XL16", hasValue:false }; var ct_PCM3 = { value:"audio/lpcm; sample-rate=8000; sample-size-bits=16; channel-count=1; is-big-endian=false", label:"Audio/PCM-LPCM", hasValue:false }; var ct_OPUS = { value:"audio/x-cbr-opus-with-preamble; preamble-size=0; bit-rate=256000; frame-size-milliseconds=4", label:"Audio/Opus", hasValue:false }; var ct_TEXT = { value:"text/plain; charset=utf-8", label:"Text", hasValue:false }; // TypedInput if (!this.contentType) this.contentType = ct_TEXT; $("#node-input-name").typedInput({ default: 'str', types: ['str'], type: 'str' }); $("#node-input-botname").typedInput({ default: 'str', types: ['str'], type: 'str' }); $("#node-input-botalias").typedInput({ default: 'str', types: ['str'], type: 'str' }); $("#node-input-output").typedInput({ default: 'msg', types: ['msg'], type: 'msg' }); $("#node-input-input").typedInput({ default: 'msg', types: ['msg','str','global'], typeField: $("#node-input-inputType") }); $("#node-input-userid").typedInput({ default: 'msg', types: ['msg','str','global'], typeField: $("#node-input-useridType") }); $("#node-input-sessionA").typedInput({ default: 'msg', types: ['msg','str','global','json'], typeField: $("#node-input-sessionAType") }); $("#node-input-requestA").typedInput({ default: 'msg', types: ['msg','str','global','json'], typeField: $("#node-input-requestAType") }); $("#node-input-content").typedInput({ types: [ct_TEXT, ct_PCM1, ct_PCM2, ct_PCM3, ct_OPUS,'str','msg'], typeField: $("#node-input-contentType") }); $("#node-input-action").change(function() { $(".post-content").hide(); if ($(this).val() === "postContent") { $(".post-content").show(); $("#node-input-content").typedInput('show'); } }) }, oneditsave: function() { } }); </script> <script type="text/x-red" data-template-name="aws-lex"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" style="width:70%;" placeholder="AWS Lex"> </div> <br> <b>AWS settings </b> <div class="form-row"> <br> <label for="node-input-token"><i class="fa fa-lock"></i> Credentials</label> <input type="text" id="node-input-token" style="width:70%;"> </div> <div class="form-row"> <label for="node-input-botname"><i class="fa fa-user"></i> Bot name</label> <input type="text" id="node-input-botname" style="width:70%;"> </div> <div class="form-row"> <label for="node-input-botalias"><i class="fa fa-user"></i> Bot alias</label> <input type="text" id="node-input-botalias" style="width:70%;"> </div> <br> <b>Requests settings</b> <div class="form-row"> <br> <label for="node-input-action"><i class="fa fa-navicon"></i> Action</label> <select id="node-input-action" style="width:70%;"> <option value="postText">Text</option> <option value="postContent">Content</option> </select> </div> <div class="form-row"> <br> <label for="node-input-input"><i class="fa fa-sign-in"></i> Input</label> <input type="text" id="node-input-input" style="width:70%;" placeholder="payload"> <input type="hidden" id="node-input-inputType"> </div> <div style="margin-left: 15px; margin-right: 0px; width: 85px; height: 1px; background-color: lightgrey; display:inline-block;"></div><!-- --><div style="margin-left: 0px; margin-right: 0px; width: 70%; height: 1px; background-color: lightgrey; display:inline-block;"></div> <br><br> <div class="form-row"> <label for="node-input-userid" style="margin-left:15px; width: 85px; color:#848484"> User ID</label> <input type="text" id="node-input-userid" style="width:70%;" placeholder="payload"> <input type="hidden" id="node-input-useridType"> </div> <div class="form-row post-content"> <label for="node-input-content" style="margin-left:15px; width: 85px; color:#848484"> Content</label> <input type="text" id="node-input-content" style="width:70%;" placeholder="payload"> <input type="hidden" id="node-input-contentType"> </div> <div class="form-row"> <label for="node-input-sessionA" style="margin-left:15px; width: 85px; color:#848484"> Session attr.</label> <input type="text" id="node-input-sessionA" style="width:70%;" placeholder="Not required"> <input type="hidden" id="node-input-sessionAType"> </div> <div class="form-row"> <label for="node-input-requestA" style="margin-left:15px; width: 85px; color:#848484"> Request attr.</label> <input type="text" id="node-input-requestA" style="width:70%;" placeholder="Not required"> <input type="hidden" id="node-input-requestAType"> </div> <div style="margin-left: 15px; margin-right: 0px; width: 85px; height: 1px; background-color: lightgrey; display:inline-block;"></div><!-- --><div style="margin-left: 0px; margin-right: 0px; width: 70%; height: 1px; background-color: lightgrey; display:inline-block;"></div> <br><br> <div class="form-row"> <label for="node-input-output"><i class="fa fa-sign-out"></i> Output</label> <input type="text" id="node-input-output" style="width:70%;" placeholder="payload"> </div> </script> <style> .help-section > ol > h4, .help-section > h3 { font-weight: bold; } </style> <script type="text/x-red" data-help-name="aws-lex"> <p>Uses AWS Lex to perform language understanding.</p> <h3>Details</h3> <p>Properties</p> <dl class="message-properties"> <dt>Credentials <span class="property-type">config</span></dt> <dd>IAM user's key and secret for AWS Lex</dd> <dt>Bot name <span class="property-type">string</span></dt> <dd>bot's name</dd> <dt>Bot alias <span class="property-type">string</span></dt> <dd>bot's alias (publication version)</dd> <dt>Input <span class="property-type">string/audio</span></dt> <dd>the sentence to analyze</dd> <dt>Session/request attributes <span class="property-type">string</span></dt> <dd>application-specific or request-specific information passed between Amazon Lex and a client application - the value must be a JSON serialized and base64 encoded map with string keys and values</dd> <dt>Output</dt> <dd>where to store the result</dd> </dl> <p>The request action can be either <i>Content</i> or <i>Text</i>. If the action is set to <i>Text</i>, the input should be a string; if the action is set to <i>Content</i>, the input depends on the <i>Content</i> field.</p> <h3>References</h3> <ul> <li><a href="https://github.com/aws/aws-sdk-js">AWS SDK</a> - the github repository</li> <li><a href="https://docs.aws.amazon.com/lex/latest/dg/API_Operations_Amazon_Lex_Runtime_Service.html">AWS Lex</a> - API reference</li> <li><a href="https://github.com/NGRP/node-red-contrib-viseo/">VISEO BotMaker</a> - the nodes github repository</li> </ul> <h3>Tracking</h3> <p>This node is likely to display an error message if no key is configured in the VISEO Bot Maker project. If such an error appears, please get a key <a href="https://key.bot.viseo.io/">here</a>. </p> </script>