2021-01-21 19:31:02 +00:00
|
|
|
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',
|
2021-02-08 07:20:11 +00:00
|
|
|
content: 'cards',
|
2021-01-21 19:31:02 +00:00
|
|
|
content_attributes: {
|
|
|
|
items: [
|
2021-02-08 07:20:11 +00:00
|
|
|
sample_card_item,
|
2021-01-21 19:31:02 +00:00
|
|
|
sample_card_item
|
|
|
|
]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.sample_card_item
|
|
|
|
{
|
2021-06-07 11:56:08 +00:00
|
|
|
media_url: 'https://i.imgur.com/d8Djr4k.jpg',
|
|
|
|
title: 'Acme Shoes 2.0',
|
|
|
|
description: 'Move with Acme Shoe 2.0',
|
|
|
|
actions: [
|
2021-01-21 19:31:02 +00:00
|
|
|
{
|
2021-06-07 11:56:08 +00:00
|
|
|
type: 'link',
|
|
|
|
text: 'View More',
|
|
|
|
uri: 'http://acme-shoes.inc'
|
2021-01-21 19:31:02 +00:00
|
|
|
},
|
|
|
|
{
|
2021-06-07 11:56:08 +00:00
|
|
|
type: 'postback',
|
|
|
|
text: 'Add to cart',
|
|
|
|
payload: 'ITEM_SELECTED'
|
2021-01-21 19:31:02 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
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: {
|
2021-06-07 11:56:08 +00:00
|
|
|
items: [
|
|
|
|
{ title: '🌯 Burito', value: 'Burito' },
|
|
|
|
{ title: '🍝 Pasta', value: 'Pasta' },
|
|
|
|
{ title: ' 🍱 Sushi', value: 'Sushi' },
|
|
|
|
{ title: ' 🥗 Salad', value: 'Salad' }
|
2021-01-21 19:31:02 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.create_sample_form_message(conversation)
|
|
|
|
Message.create!(
|
|
|
|
account: conversation.account,
|
|
|
|
inbox: conversation.inbox,
|
|
|
|
conversation: conversation,
|
|
|
|
message_type: :template,
|
|
|
|
content_type: 'form',
|
2021-02-08 07:20:11 +00:00
|
|
|
content: 'form',
|
2021-06-08 11:02:01 +00:00
|
|
|
content_attributes: sample_form
|
2021-01-21 19:31:02 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2021-06-08 11:02:01 +00:00
|
|
|
def self.sample_form
|
|
|
|
{
|
|
|
|
"items": [
|
|
|
|
{ "name": 'email', "placeholder": 'Please enter your email', "type": 'email', "label": 'Email', "required": 'required',
|
|
|
|
"pattern_error": 'Please fill this field', "pattern": '^[^\s@]+@[^\s@]+\.[^\s@]+$' },
|
|
|
|
{ "name": 'text_area', "placeholder": 'Please enter text', "type": 'text_area', "label": 'Large Text', "required": 'required',
|
|
|
|
"pattern_error": 'Please fill this field' },
|
|
|
|
{ "name": 'text', "placeholder": 'Please enter text', "type": 'text', "label": 'text', "default": 'defaut value', "required": 'required',
|
|
|
|
"pattern": '^[a-zA-Z ]*$', "pattern_error": 'Only alphabets are allowed' },
|
|
|
|
{ "name": 'select', "label": 'Select Option', "type": 'select', "options": [{ "label": '🌯 Burito', "value": 'Burito' },
|
|
|
|
{ "label": '🍝 Pasta', "value": 'Pasta' }] }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2021-01-21 19:31:02 +00:00
|
|
|
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: {
|
2021-06-07 11:56:08 +00:00
|
|
|
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' }
|
2021-01-21 19:31:02 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|