-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
bot.html
95 lines (83 loc) · 3.04 KB
/
bot.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<script type="text/javascript">
RED.nodes.registerType('whatsapp-bot', {
category: 'Whatsapp Bot',
color: '#25D366',
defaults: {
name: {
value: ''
},
client: {
type: 'whatsapp-client',
required: true
},
},
inputs: 1,
outputs: 1,
align: "left",
icon: 'whatsapp.png',
paletteLabel: 'Whatsapp Bot',
label: function () {
return this.name || 'Whatsapp Bot'
}
})
</script>
<script type="text/html" data-template-name="whatsapp-bot">
<div class="form-row">
<label for="node-input-client"><i class="icon-globe"></i> <span> Client</span></label>
<input type="text" id="node-input-client">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/html" data-help-name="whatsapp-bot">
<p>Used to send/receive data from a Whatsapp Client. Each Bot node by default subscribes to <code>onMessage</code>, <code>onAck</code> and <code>onAddedToGroup</code> events</p>
<h3>Input</h3>
<ol class="node-ports">
<li>Input
<dl class="message-properties">
<dt>topic <span class="property-type">String</span></dt>
<dd>API/Event name</dd>
</dl>
<dl class="message-properties">
<dt>payload <span class="property-type">Array</span></dt>
<dd>Args to use to call the API</dd>
</dl>
</li>
</ol>
<h3>Outputs</h3>
<ol class="node-ports">
<li>Output
<dl class="message-properties">
<dt>payload <span class="property-type">Array</span></dt>
<dd>Args result of the api/event</dd>
</dl>
<dl class="message-properties">
<dt>topic <span class="property-type">String</span></dt>
<dd>API name</dd>
</dl>
</li>
</ol>
<h3>Examples</h3>
<p>If you want to subscribe to <code>onParticipantsChanged</code> or <code>onLiveLocation</code>, send the request with only the <code>chatId</code> and
it will subscribe for those events on that chat. The output <code>msg</code> contain also a property <code>chatId</code> with the id of the chat that has emitted the event</p>
<p>Function node code for calling <code>sendMessageToId</code> API:</p>
<code>
msg.payload = { topic: 'sendMessageToId', payload: [ '[email protected]', 'Hello from Node-Red'] }
return msg
</code>
<p>Result of previous message:</p>
<code>
{ topic: 'sendMessageToId', payload: [ '[email protected]_xxxxxxxxxxxx' ], origin: { //the origin message request } }
</code>
<p>Output for an <code>onMessage</code> event:</p>
<code>
{ topic: 'onMessage', payload: [ { // the message object } ] }
</code>
<h3>References</h3>
<ul>
<li><a href="https://github.com/danielcardeenas/sulla">APIs</a> - List of available apis</li>
<li><a href="https://github.com/robertsLando/node-red-contrib-whatsappbot">GitHub</a> - the node github repository</li>
</ul>
</script>