forked from chatwoot/chatwoot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwoot_message_seeder.rb
103 lines (98 loc) · 2.96 KB
/
woot_message_seeder.rb
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
module WootMessageSeeder
def self.create_sample_email_collect_message(conversation)
Message.create!(
account: conversation.account,
inbox: conversation.inbox,
conversation: conversation,
message_type: :template,
content_type: :input_email,
content: 'Get notified by email'
)
end
def self.create_sample_cards_message(conversation)
Message.create!(
account: conversation.account,
inbox: conversation.inbox,
conversation: conversation,
message_type: :template,
content_type: 'cards',
content: 'cards',
content_attributes: {
items: [
sample_card_item,
sample_card_item
]
}
)
end
def self.sample_card_item
{
"media_url": 'https://i.imgur.com/d8Djr4k.jpg',
"title": 'Acme Shoes 2.0',
"description": 'Move with Acme Shoe 2.0',
"actions": [
{
"type": 'link',
"text": 'View More',
"uri": 'http://acme-shoes.inc'
},
{
"type": 'postback',
"text": 'Add to cart',
"payload": 'ITEM_SELECTED'
}
]
}
end
def self.create_sample_input_select_message(conversation)
Message.create!(
account: conversation.account,
inbox: conversation.inbox,
conversation: conversation,
message_type: :template,
content: 'Your favorite food',
content_type: 'input_select',
content_attributes: {
"items": [
{ "title": '🌯 Burito', "value": 'Burito' },
{ "title": '🍝 Pasta', "value": 'Pasta' },
{ "title": ' 🍱 Sushi', "value": 'Sushi' },
{ "title": ' 🥗 Salad', "value": 'Salad' }
]
}
)
end
def self.create_sample_form_message(conversation)
Message.create!(
account: conversation.account,
inbox: conversation.inbox,
conversation: conversation,
message_type: :template,
content_type: 'form',
content: 'form',
content_attributes: {
"items": [
{ "name": 'email', "placeholder": 'Please enter your email', "type": 'email', "label": 'Email' },
{ "name": 'text_aread', "placeholder": 'Please enter text', "type": 'text_area', "label": 'Large Text' },
{ "name": 'text', "placeholder": 'Please enter text', "type": 'text', "label": 'text', "default": 'defaut value' }
]
}
)
end
def self.create_sample_articles_message(conversation)
Message.create!(
account: conversation.account,
inbox: conversation.inbox,
conversation: conversation,
message_type: :template,
content: 'Tech Companies',
content_type: 'article',
content_attributes: {
"items": [
{ "title": 'Acme Hardware', "description": 'Hardware reimagined', "link": 'http://acme-hardware.inc' },
{ "title": 'Acme Search', "description": 'The best Search Engine', "link": 'http://acme-search.inc' }
]
}
)
end
end