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
81 lines (78 loc) • 4 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('chatbot-parse', {
category: 'RedBot Parsers',
color: '#FFCC66',
defaults: {
name: {
value: ''
},
parseType: {
value: 'string'
},
parseVariable: {
value: 'string'
}
},
inputs: 1,
outputs: 2,
icon: 'chatbot-parse.png',
paletteLabel: 'Parse',
label: function() {
return this.name || 'chatbot-parse';
}
});
</script>
<script type="text/x-red" data-template-name="chatbot-parse">
<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-name"><i class="icon-cog"></i> Type</label>
<select id="node-input-parseType">
<option value="audio">Audio</option>
<option value="contact">Contact</option>
<option value="response">Dialog response</option>
<option value="document">Document</option>
<option value="email">Email</option>
<option value="number-integer">Integer number</option>
<option value="location">Location</option>
<option value="photo">Photo</option>
<option value="video">Video</option>
<option value="string">String</option>
<option value="boolean">Yes or No</option>
</select>
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-bookmark"></i> Variable</label>
<input type="text" id="node-input-parseVariable" placeholder="Store into variable name">
<div style="max-width: 460px;font-size: 12px;color: #999999;line-height: 14px;margin-top:5px;">
The parsed value will be store in the chat flow. Use the in messages with a handlebars like syntax
<code>{{my_variable}}</code> or in a function block
<br><br>
<pre>
var chat = msg.chat();
var my_var = chat.get('my_variable');
</pre>
</div>
</div>
</script>
<script type="text/x-red" data-help-name="chatbot-parse"><p>Parse the inbound chat message and extract a specific type (string, number, email, location, etc) then store the value in the context flow and pass through the output pin (in <code>msg.payload</code>)</p>
<p>Available parse type are:</p>
<ul>
<li><strong>string</strong>: any payload of type string will be accepted</li>
<li><strong>boolean</strong>: returns <code>true</code> for any words like <em>yes</em>, <em>true</em>, _ok_, etc</li>
<li><strong>email</strong>: extract a valid email in the incoming message</li>
<li><strong>date</strong>: extract a valid date from the incoming message</li>
<li><strong>integer-number</strong>: extract a integer number (written in numbers or plain english)</li>
<li><strong>location</strong>: extract the location from a <code>location</code> chat message (the one sent by the chat client when the user shares the position). The value extracted will be something like
<code>{latitude: 45.001, longitude: 21.001}</code></li>
<li><strong>contact</strong>: extract the phone number from a contact type message (a user that shares a contact)</li>
<li><strong>photo</strong>: extract the image from a chat message containing a picture, the resulting payload is suitable to be sent to file node (a NodeJS Buffer)</li>
<li><strong>audio</strong>: extract the audio payload from an audio chat message, the resulting payload is suitable to be sent to file node. Audio format depends on platform (for example <strong>Telegram</strong>: <em>Ogg Vorbis (*.ogg)</em></li>
</ul>
<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">
<img src="https://img.shields.io/badge/platform-Smooch-orange.svg" alt="Smooch"></p>
</script>