bamboo v1.3.0 Bamboo.SendGridHelper View Source

Functions for using features specific to Sendgrid.

Example

email
|> with_template("80509523-83de-42b6-a2bf-54b7513bd2aa")
|> substitute("%name%", "Jon Snow")
|> substitute("%location%", "Westeros")

Link to this section Summary

Functions

Add a property to the list of dynamic template data in the SendGrid template. This will be added to the request as

Add a tag to the list of substitutions in the SendGrid template.

An integer id for an ASM (Advanced Suppression Manager) group that this email should belong to. This can be used to let recipients unsubscribe from only a certain type of communication.

A boolean setting to instruct SendGrid to bypass list management for this email. If enabled, SendGrid will ignore any email supression (such as unsubscriptions, bounces, spam filters) for this email. This is useful for emails that all users must receive, such as Terms of Service updates, or password resets.

An array of category names for this email. A maximum of 10 categories can be assigned to an email. Duplicate categories will be ignored and only unique entries will be sent.

Instruct SendGrid to enable or disable Google Analytics tracking, and optionally set the UTM parameters for it. This is useful if you need to control UTM tracking parameters on an individual email basis.

Specify the template for SendGrid to use for the context of the substitution tags.

Link to this section Functions

Link to this function

add_dynamic_field(email, field, value) View Source

Add a property to the list of dynamic template data in the SendGrid template. This will be added to the request as:

... "personalizations":[

{
   "to":[
      {
         "email":"example@sendgrid.net"
      }
   ],
   "dynamic_template_data":{
      "total":"$ 239.85",
   }
}

], ...

The tag can be of any type since SendGrid allows you to use Handlebars in its templates

Example

email
|> add_data("name", "Jon Snow")
Link to this function

substitute(email, tag, value) View Source

Add a tag to the list of substitutions in the SendGrid template.

The tag must be a String.t due to SendGrid using special characters to wrap tags in the template.

Example

email
|> substitute("%name%", "Jon Snow")
Link to this function

with_asm_group_id(email, asm_group_id) View Source

An integer id for an ASM (Advanced Suppression Manager) group that this email should belong to. This can be used to let recipients unsubscribe from only a certain type of communication.

Example

email
|> with_asm_group_id(1234)
Link to this function

with_bypass_list_management(email, enabled) View Source

A boolean setting to instruct SendGrid to bypass list management for this email. If enabled, SendGrid will ignore any email supression (such as unsubscriptions, bounces, spam filters) for this email. This is useful for emails that all users must receive, such as Terms of Service updates, or password resets.

Example

email
|> with_bypass_list_management(true)
Link to this function

with_categories(email, categories) View Source

An array of category names for this email. A maximum of 10 categories can be assigned to an email. Duplicate categories will be ignored and only unique entries will be sent.

Example

email
|> with_categories("campaign-12345")
Link to this function

with_google_analytics(email, enabled, utm_params \\ %{}) View Source

Instruct SendGrid to enable or disable Google Analytics tracking, and optionally set the UTM parameters for it. This is useful if you need to control UTM tracking parameters on an individual email basis.

Example

email
|> with_google_analytics(true, %{utm_source: "email", utm_campaign: "campaign"})

email
|> with_google_analytics(false)
Link to this function

with_template(email, template_id) View Source

Specify the template for SendGrid to use for the context of the substitution tags.

Example

email
|> with_template("80509523-83de-42b6-a2bf-54b7513bd2aa")