Class: Telerivet::MessageTemplate
- Defined in:
- lib/telerivet/messagetemplate.rb
Overview
Represents a reusable message template that can be used when composing or scheduling messages.
Message templates can include placeholder variables using double square
brackets (e.g. [[contact.name]]) that are replaced with actual values when the message is
sent. For available variables, see Variable Reference. The double square
brackets may also include filters to transform variables, such
as to set a default value.
Templates synchronized from a WhatsApp Business Account are read-only and cannot be modified or deleted via the API. (When using Telerivet to send messages via a WhatsApp route, Telerivet tries to match the content of each outgoing message to one of these WhatsApp message templates. If a template matches, Telerivet sends a WhatsApp template message instead of a session message.)
Fields:
- id (string, max 34 characters)
* ID of the message template
* Read-only
- name (string)
* Name of the template (max 127 characters)
* Updatable via API
- content (string)
* Content of the message template (max 2000 characters)
* Updatable via API
- track_clicks (bool)
* If true, URLs in the content will be replaced with short links that track clicks
when the template is used
* Updatable via API
- readonly (bool)
* True if the template cannot be modified or deleted (i.e., it was synchronized from a
WhatsApp Business Account)
* Read-only
- short_link_params (Hash)
* Custom parameters for short links (only if track_clicks is true)
* Updatable via API
- attachments (array)
* List of attachment objects with file URLs
* Updatable via API
- route_params (Hash)
* Route-specific parameters to use when sending messages with this template.
When sending messages via chat apps such as WhatsApp, the route_params
parameter can be used to send messages with app-specific features such as quick
replies and link buttons.
For more details, see [Route-Specific Parameters](#route_params).
* Updatable via API
- waba_id (string)
* ID of the WhatsApp Business Account that this template is associated with (only
present for WhatsApp templates)
* Read-only
- whatsapp_template (Hash)
* For templates synchronized from a WhatsApp Business Account, contains the full
template data from WhatsApp with properties including `id`, `name`, `language`,
`status`, `category`, and `components`. The full format is defined in the [WhatsApp
Template API
documentation](https://developers.facebook.com/documentation/business-messaging/whatsapp/reference/whatsapp-business-account/template-api#get-version-template-id).
Only present for WhatsApp templates.
* Read-only
- time_created (UNIX timestamp)
* Time the template was created in Telerivet
* Read-only
- time_updated (UNIX timestamp)
* Time the template was last updated
* Read-only
- vars (Hash)
* Custom variables stored for this template. Variable names may be up to 32 characters
in length and can contain the characters a-z, A-Z, 0-9, and _.
Values may be strings, numbers, or boolean (true/false).
String values may be up to 4096 bytes in length when encoded as UTF-8.
Up to 100 variables are supported per object.
Setting a variable to null will delete the variable.
* Updatable via API
- project_id
* ID of the project this template belongs to
* Read-only
Instance Method Summary collapse
- #attachments ⇒ Object
- #attachments=(value) ⇒ Object
- #content ⇒ Object
- #content=(value) ⇒ Object
-
#delete ⇒ Object
Deletes the message template.
- #get_base_api_path ⇒ Object
- #id ⇒ Object
- #name ⇒ Object
- #name=(value) ⇒ Object
- #project_id ⇒ Object
- #readonly ⇒ Object
- #route_params ⇒ Object
- #route_params=(value) ⇒ Object
-
#save ⇒ Object
Saves any fields that have changed for the message template.
- #short_link_params ⇒ Object
- #short_link_params=(value) ⇒ Object
- #time_created ⇒ Object
- #time_updated ⇒ Object
- #track_clicks ⇒ Object
- #track_clicks=(value) ⇒ Object
- #waba_id ⇒ Object
- #whatsapp_template ⇒ Object
Methods inherited from Entity
#get, #initialize, #load, #set, #set_data, #to_s, #vars
Constructor Details
This class inherits a constructor from Telerivet::Entity
Instance Method Details
#attachments ⇒ Object
155 156 157 |
# File 'lib/telerivet/messagetemplate.rb', line 155 def get('attachments') end |
#attachments=(value) ⇒ Object
159 160 161 |
# File 'lib/telerivet/messagetemplate.rb', line 159 def (value) set('attachments', value) end |
#content ⇒ Object
127 128 129 |
# File 'lib/telerivet/messagetemplate.rb', line 127 def content get('content') end |
#content=(value) ⇒ Object
131 132 133 |
# File 'lib/telerivet/messagetemplate.rb', line 131 def content=(value) set('content', value) end |
#delete ⇒ Object
Deletes the message template.
Note: Templates synchronized from a WhatsApp Business Account cannot be deleted via the API.
111 112 113 |
# File 'lib/telerivet/messagetemplate.rb', line 111 def delete() @api.do_request("DELETE", get_base_api_path()) end |
#get_base_api_path ⇒ Object
191 192 193 |
# File 'lib/telerivet/messagetemplate.rb', line 191 def get_base_api_path() "/projects/#{get('project_id')}/message_templates/#{get('id')}" end |
#id ⇒ Object
115 116 117 |
# File 'lib/telerivet/messagetemplate.rb', line 115 def id get('id') end |
#name ⇒ Object
119 120 121 |
# File 'lib/telerivet/messagetemplate.rb', line 119 def name get('name') end |
#name=(value) ⇒ Object
123 124 125 |
# File 'lib/telerivet/messagetemplate.rb', line 123 def name=(value) set('name', value) end |
#project_id ⇒ Object
187 188 189 |
# File 'lib/telerivet/messagetemplate.rb', line 187 def project_id get('project_id') end |
#readonly ⇒ Object
143 144 145 |
# File 'lib/telerivet/messagetemplate.rb', line 143 def readonly get('readonly') end |
#route_params ⇒ Object
163 164 165 |
# File 'lib/telerivet/messagetemplate.rb', line 163 def route_params get('route_params') end |
#route_params=(value) ⇒ Object
167 168 169 |
# File 'lib/telerivet/messagetemplate.rb', line 167 def route_params=(value) set('route_params', value) end |
#save ⇒ Object
Saves any fields that have changed for the message template.
102 103 104 |
# File 'lib/telerivet/messagetemplate.rb', line 102 def save() super end |
#short_link_params ⇒ Object
147 148 149 |
# File 'lib/telerivet/messagetemplate.rb', line 147 def short_link_params get('short_link_params') end |
#short_link_params=(value) ⇒ Object
151 152 153 |
# File 'lib/telerivet/messagetemplate.rb', line 151 def short_link_params=(value) set('short_link_params', value) end |
#time_created ⇒ Object
179 180 181 |
# File 'lib/telerivet/messagetemplate.rb', line 179 def time_created get('time_created') end |
#time_updated ⇒ Object
183 184 185 |
# File 'lib/telerivet/messagetemplate.rb', line 183 def time_updated get('time_updated') end |
#track_clicks ⇒ Object
135 136 137 |
# File 'lib/telerivet/messagetemplate.rb', line 135 def track_clicks get('track_clicks') end |
#track_clicks=(value) ⇒ Object
139 140 141 |
# File 'lib/telerivet/messagetemplate.rb', line 139 def track_clicks=(value) set('track_clicks', value) end |
#waba_id ⇒ Object
171 172 173 |
# File 'lib/telerivet/messagetemplate.rb', line 171 def waba_id get('waba_id') end |
#whatsapp_template ⇒ Object
175 176 177 |
# File 'lib/telerivet/messagetemplate.rb', line 175 def whatsapp_template get('whatsapp_template') end |