-
Notifications
You must be signed in to change notification settings - Fork 1
/
message.js
51 lines (49 loc) · 981 Bytes
/
message.js
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
function Message(){}
/*
* @param this dictionary
* @param payload
*/
Message.prototype.addTemplate = function(payload)
{
this["attachment"] = {
"type":"template",
"payload":payload
};
return this;
}
/*
* @param this dictionary
* @param text string this to be send
*/
Message.prototype.addText = function(text)
{
this.text = text;
return this;
}
/*
* @param title string
* @param payload the return data that needs to be handled
* @param image_url image to be displayed
* @param type should be text/email/phone
*/
Message.prototype.createReply = function(title,payload,image_url=null,type="text")
{
var data = {
"content_type": type,
"title": title,
"payload":payload
};
if (image_url)
{
data["image_url"] = image_url;
}
if (this["quick_replies"])
{
this.quick_replies.push(data);
}
else
{
this.quick_replies = [data];
}
return this;
}