forked from guidone/node-red-contrib-chatbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatbot-facebook-receive.html
173 lines (162 loc) · 5.52 KB
/
chatbot-facebook-receive.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<script type="text/javascript">
RED.nodes.registerType('chatbot-facebook-node', {
category: 'config',
defaults: {
botname: {
value: '',
required: true
},
usernames: {
value: '',
required: false
},
log: {
value: null
}
},
paletteName: 'Facebook Bot',
credentials: {
token: {
type: 'text'
},
verify_token: {
type: 'text'
},
app_secret: {
type: 'text'
}
},
label: function () {
return this.botname;
}
});
</script>
<script type="text/x-red" data-template-name="chatbot-facebook-node">
<div class="form-row">
<label for="node-config-input-botname"><i class="icon-bookmark"></i> Bot-Name</label>
<input type="text" id="node-config-input-botname">
</div>
<div class="form-row">
<label for="node-config-input-token"><i class="icon-cog"></i> Token</label>
<input type="text" id="node-config-input-token" placeholder="Access Token">
<div style="max-width: 460px;font-size: 12px;color: #999999;line-height: 14px;margin-top:5px;">
The access token that is generated when the Facebook app is connected to a Facebook page
</div>
</div>
<div class="form-row">
<label for="node-config-input-app_secret"><i class="icon-cog"></i> App Secret</label>
<input type="text" id="node-config-input-app_secret" placeholder="App secret">
<div style="max-width: 460px;font-size: 12px;color: #999999;line-height: 14px;margin-top:5px;">
This is the app secret, find it in the "dashboard" section of the Facebook app
</div>
</div>
<div class="form-row">
<label for="node-config-input-verify_token"><i class="icon-random"></i> Verify</label>
<input type="text" id="node-config-input-verify_token" placeholder="Verify token">
<div style="max-width: 460px;font-size: 12px;color: #999999;line-height: 14px;margin-top:5px;">
The verify token is an arbitrary string, must match the same string in the "Webhooks" section in the
Facebook app
</div>
</div>
<div class="form-row">
<label for="node-config-input-usernames"><i class="icon-user"></i> Users</label>
<input type="text" id="node-config-input-usernames" placeholder="Authorized users">
<div style="max-width: 460px;font-size: 12px;color: #999999;line-height: 14px;margin-top:5px;">
Comma separated list of userId authorized to use the chatBot
</div>
</div>
<div class="form-row">
<label for="node-config-input-log"><i class="icon-file"></i> Log file</label>
<input type="text" id="node-config-input-log">
<div style="max-width: 460px;font-size: 12px;color: #999999;line-height: 14px;margin-top:5px;">
Store inbound and outbound messages to file
</div>
</div>
</script>
<script type="text/x-red" data-help-name="chatbot-facebook-node">
<p>
Configure the Facebook chat bot
</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('chatbot-facebook-receive', {
category: 'RedBot Platforms',
color: '#FFCC66',
defaults: {
bot: {
value: '',
type: 'chatbot-facebook-node',
required: true
}
},
inputs: 0,
outputs: 1,
icon: 'chatbot-receiver.png',
paletteLabel: 'Facebook In',
label: function () {
return "Facebook Receiver";
}
});
</script>
<script type="text/x-red" data-template-name="chatbot-facebook-receive">
<div class="form-row">
<label for="node-input-bot"><i class="icon-bookmark"></i> Bot</label>
<input type="text" id="node-input-bot" placeholder="Bot">
</div>
</script>
<script type="text/x-red" data-help-name="chatbot-facebook-receive">
<p>Receive a message (text, audio, video, image, etc) from a Facebook Messenger bot.</p>
<p>The message is stored in <code>msg.payload</code>, this node also stores in the context flow:
<code>username</code>, <code>firstName</code>, <code>lastName</code>, <code>chatId</code>, <code>authorized</code>,
<code>transport</code> and <code>messageId</code>.
</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('chatbot-facebook-send', {
category: 'RedBot Platforms',
color: '#FFCC66',
defaults: {
bot: {
value: "",
type: 'chatbot-facebook-node',
required: true
},
track: {
value: false
},
outputs: {
value: 0
}
},
inputs: 1,
outputs: 0,
icon: 'chatbot-sender.png',
paletteLabel: 'Facebook Out',
label: function () {
return "Facebook Sender";
},
oneditsave: function() {
var track = $('#node-input-track').is(':checked');
this.outputs = track ? 1 : 0;
}
});
</script>
<script type="text/x-red" data-template-name="chatbot-facebook-send">
<div class="form-row">
<label for="node-input-bot"><i class="icon-bookmark"></i> Bot</label>
<input type="text" id="node-input-bot" placeholder="Bot">
</div>
<div class="form-row">
<label for="node-input-track"><i class="icon-envelope"></i> Track</label>
<input type="checkbox" value="true" id="node-input-track">
<div style="max-width: 460px;font-size: 12px;color: #999999;line-height: 14px;margin-top:5px;">
Track response of the user for this message, any further answer will be redirect to the output pin.
</div>
</div>
</script>
<script type="text/x-red" data-help-name="chatbot-facebook-send">
<p>
Send a message (text, audio, video, image, etc) from a Facebook Messenger bot. In order to create complex conversations, it
can track answers from the user using output pin.
</p>
</script>