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

83 lines (80 loc) 3.74 kB
<script type="text/javascript"> $.RedBot.registerType('chatbot-parse', { category: $.RedBot.config.name + ' 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: - <strong>string</strong>: any payload of type string will be accepted </p> <ul> <li><p><strong>boolean</strong>: returns <code>true</code> for any words like <em>yes</em>, <em>true</em>, <em>ok</em>, etc </p> </li> <li><p><strong>email</strong>: extract a valid email in the incoming message </p> </li> <li><p><strong>date</strong>: extract a valid date from the incoming message </p> </li> <li><p><strong>integer-number</strong>: extract a integer number (written in numbers or plain english)</p> </li> <li><p><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> </p> </li> <li><p><strong>contact</strong>: extract the phone number from a contact type message (a user that shares a contact) </p> </li> <li><p><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) </p> </li> <li><p><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></p> </li> </ul> </script>