UNPKG

node-red-contrib-chatbot

Version:

REDBot a Chat bot for a full featured chat bot for Telegram, Facebook Messenger and Slack. Almost no coding skills required

80 lines (77 loc) 2.62 kB
<script type="text/javascript"> $.RedBot.registerType('chatbot-audio', { category: $.RedBot.config.name, color: '#FFCC66', defaults: { name: { value: '' }, audio: { value: '' }, duration: { value: '' }, track: { value: false } }, inputs: 1, outputs: 1, icon: 'chatbot-audio.png', paletteLabel: 'Audio', label: function() { return this.name || 'Audio'; }, oneditprepare: function() { $.RedBot.fetchPlatforms() .done(function(platforms) { $('#dialog-form').RB_Platforms(); }); } }); </script> <script type="text/x-red" data-template-name="chatbot-audio"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-audio">Audio</label> <input type="text" id="node-input-audio" placeholder="Audio file or URL"> </div> <div class="form-row"> <label for="node-input-duration">Duration</label> <input type="text" id="node-input-duration" placeholder="Duration in seconds"> <div class="redbot-platforms telegram"/> </div> </script> <script type="text/x-red" data-help-name="chatbot-audio"><p>The <code>Audio node</code> sends an audio to the chatbot from a local file or from a URL or from a Buffer passed by an upstream node (the simplest way to use it to chain with to <code>File node</code> or a <code>Http node</code>).</p> <p>To programmatically send an audio with a <code>Function node</code></p> <pre><code class="language-javascript">msg.payload.document = &#39;/my-file.mp3&#39;;return msg; </code></pre> <p>Or using a <code>Buffer</code></p> <pre><code class="language-javascript">msg.payload.document = new Buffer(&lt;my-mp3-buffer&gt;);msg.payload.filename = &#39;my-file.pdf&#39;;return msg; </code></pre> <p>In case the upstream node pass through a <code>Buffer</code>, the node tries to extract a proper file name (visible to user in the chat client) using the payload of the upstream <code>File node</code> or the name of the node itself.</p> <p>Available parameters for the <code>msg.payload</code></p> <table> <thead> <tr> <th>Name</th> <th>Type</th> <th>Description</th> </tr> </thead> <tbody><tr> <td>audio</td> <td>string or buffer</td> <td>The audio string could be a path for a local file or a URL (context variables can be used)</td> </tr> <tr> <td>caption</td> <td>string</td> <td>Caption of the audio. Only for Telegram, Slack and Viber</td> </tr> </tbody></table> </script>