forked from guidone/node-red-contrib-chatbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatbot-parse.html
79 lines (77 loc) · 3.05 KB
/
chatbot-parse.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<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="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="chatbot-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. Audio format depends on platform. Telegram: <em>Ogg Vorbis (*.ogg)</em></li>
</ul>
</p>
</script>