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
69 lines (61 loc) • 2.63 kB
HTML
<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';
}
});
</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>
</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="lang-javascript">msg.payload.document = '/my-file.mp3';
return msg;
</code></pre>
<p>Or using a <code>Buffer</code>:</p>
<pre><code class="lang-javascript">msg.payload.document = new Buffer(<my-mp3-buffer>);
msg.payload.filename = 'my-file.pdf';
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>
<dl class="message-properties">
<dt>audio<span class="property-type">string or buffer</span><dd>The audio string could be a path for a local file or a URL (context variables can be used)</dd>
<dt>caption<span class="property-type">string</span><dd>Caption of the audio. Only for Telegram, Slack and Viber</dd>
</dl>
<p><img src="https://img.shields.io/badge/platform-Telegram-blue.svg?colorB=7cbaea" alt="Telegram">
<img src="https://img.shields.io/badge/platform-Facebook-blue.svg" alt="Facebook">
<img src="https://img.shields.io/badge/platform-Slack-green.svg" alt="Slack"></p>
</script>