Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dynamic Template Support #301

Closed
thinkingserious opened this issue Jul 26, 2018 · 13 comments
Closed

Add Dynamic Template Support #301

thinkingserious opened this issue Jul 26, 2018 · 13 comments
Labels
difficulty: medium fix is medium in difficulty type: twilio enhancement feature request on Twilio's roadmap

Comments

@thinkingserious
Copy link
Contributor

Issue Summary

On 7/24/2018, our team publicly launched dynamic content for transactional templates. It is now available for all customers sending over v3 of our Mail Send API. Iterate over lists, handle conditionals and more, thanks to native support for a subset of Handlebars syntax!

More information can be found in our blog post announcement.

You can currently use this feature by manually creating the request body as shown here.

Now, we need to create helper code and examples for this SDK.

Acceptance Criteria

Documentation

@thinkingserious thinkingserious added status: work in progress Twilio or the community is in the process of implementing difficulty: medium fix is medium in difficulty type: twilio enhancement feature request on Twilio's roadmap labels Jul 26, 2018
@thinkingserious
Copy link
Contributor Author

Please see #300 for WIP

@metaskills
Copy link

I'd like to point out the the docs and the article have the template_id in the wrong spot. It should be outside the personalizations array at the root.

@thinkingserious
Copy link
Contributor Author

Hi @metaskills,

Are you referring this documentation? If so, it looks like a fix will be deployed soon.

Thanks!

With Best Regards,

Elmer

@metaskills
Copy link

Yes, I found that template_id is in the wrong spot there.

@thinkingserious
Copy link
Contributor Author

Thanks for confirming @metaskills. I'm double checking with the docs team to make sure the fix is deployed.

@heindrik
Copy link

heindrik commented Oct 4, 2018

Hi all,

Has the gem been updated with the new helper methods for dynamic template? I am asking cause I am using gem version 5.2 and I am getting the following error

Exception encountered: NoMethodError - undefined method `add_dynamic_template_data' for #<SendGrid::Personalization:0x00005615d7b5ae08>

@thinkingserious
Copy link
Contributor Author

Not yet @heindrik, please follow this page for updates or you can subscribe to our release notification emails here. Thanks!

@hiroshi
Copy link

hiroshi commented Oct 9, 2018

For those who want to use helpers for other parts

mail = SendGrid::Mail.new
...
personalization = SendGrid::Personalization.new
personalization.add_to(SendGrid::Email.new(email: user_email))
mail.add_personalization(personalization)
...
body = mail.to_json
# TODO: use helper after the issue resolved https://github.com/sendgrid/sendgrid-ruby/issues/301             
body['personalizations'][0]['dynamic_template_data'] = {                                                   
  foo: 'bar'
}                                                                                                          
sg_client = SendGrid::API.new(api_key: YOUR_API_KEY).client
resp = sg_client.mail._('send').post(request_body: body)
unless resp.status_code == '202'
  raise "Error response from sendgrid API: status_code: #{resp.status_code}, body: #{resp.body}"
end

@Davidslv
Copy link

I can't understand how it can take so long to release this, specially when the information given is that we are waiting because of other languages.
Anyway, I'm using the code straight from master branch which includes the dynamic template data.
There was no need to make us wait so long.

@devsi
Copy link

devsi commented Dec 4, 2019

Docs are still out of date. I had to search for this PR and https://github.com/sendgrid/sendgrid-ruby/pull/300 this related link to realize I couldn't use "substitutions". How is this a year out of date and not in the docs yet?!

@courtsimas
Copy link

It blows my mind that a company as large as SendGrid still hasn't updated their docs to reflect this, nor have they updated this gem to work with their new API.

@evandertino
Copy link

evandertino commented Aug 26, 2020

I think this issue should be closed, dynamic templates work. See https://github.com/sendgrid/sendgrid-ruby/blob/main/examples/helpers/mail/example.rb

@childish-sambino
Copy link
Contributor

Example here as well: https://github.com/sendgrid/sendgrid-ruby/blob/main/use-cases/transactional-templates.md#with-mail-helper-class

Closing.

Please open a new ticket to track any additional docs work needed.

@childish-sambino childish-sambino removed the status: work in progress Twilio or the community is in the process of implementing label Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty type: twilio enhancement feature request on Twilio's roadmap
Projects
None yet
Development

No branches or pull requests

9 participants