UNPKG

prisme-flow

Version:

prisme platform flow engine

87 lines (81 loc) 3.14 kB
<!-- Created by prisme.io on 09/06/2017. @author <a href="mailto:hello@prisme.io">savane vamara</a> (prisme.io) --> <script type="text/javascript"> RED.nodes.registerType('bot-parse', { category: 'bot', color: '#FFCC66', defaults: { name: { value: '' }, parseType: { value: 'string' }, parseVariable: { value: 'string' } }, inputs: 1, outputs: 2, icon: 'parse.png', paletteLabel: 'parse', label: function() { return this.name || 'bot-parse'; } }); </script> <script type="text/x-red" data-template-name="bot-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="email">Email</option> <option value="boolean">Yes or No</option> <option value="contact">Contact</option> <option value="location">Location</option> <option value="string">String</option> <option value="number-integer">Integer number</option> <option value="photo">Photo</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="bot-parse"> <p>Parse the inbound chat message by type (string, number, email, location, etc) and store the value in the context flow and pass through the output pin </p> <p> Available parse type are: <ul> <li><b>string:</b> any payload of type string will be accepted</li> <li><b>email:</b> parse a valid email</li> <li><b>integer number:</b> parse a integer number (written in numbers or plain english)</li> <li><b>integer:</b> parse a valid integer number</li> <li><b>location:</b> extract the location from a <code>location</code> chat message, payload (and the value stored in the variable) will be <code>{latitude: xxxx, longitude: yyyy}</code></li> <li><b>contact:</b> extract the phone number from a contact type message (a user that shares a contact)</li> <li><b>photo:</b> extract the image from a chat message containing a picture, the resulting payload is suitable to be sent to file node</li> <li><b>audio:</b> extract the audio payload from an audio chat message, the resulting payload is suitable to be sent to file node</li> </ul> </p> </script>