sendgrid-python icon indicating copy to clipboard operation
sendgrid-python copied to clipboard

Updating footer Sender_Name, Sender_Address, etc for dynamic template

Open bridger opened this issue 8 years ago • 35 comments

Issue Summary

I'm using a dynamic template created in the visual editor for a transactional email. I used the standard Footer module, which includes placeholders for [Sender_Name], [Sender_Address], etc. I can't figure out how to fill those placeholders with my information.

Steps to Reproduce

I'm using the following to send the email:

  data = {
    "personalizations": [
      {
        "to": [
          {
            "email": email
          }
        ],
        "dynamic_template_data": {
            "subscribe-link" : subscribeLink
        }
      }
    ],
    "from": {
      "email": "[email protected]",
      "name": "Bridger"
    },
    "template_id": template_id,
    "asm": {
      "group_id": subcription_management_group_id
    },
    "substitutions": {
      "[Sender_Name]": "Scribble LLC",
      "Sender_City": "New York, New York" # Also tried it without the brackets
    }
  }

  response = sg.client.mail.send.post(request_body=data)

I've also tried using "Sender_Name" in the dynamic_template_data object, but no luck.

There is a section that sort of addresses this issue at https://sendgrid.com/docs/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates/, but I don't understand how to copy the dynamic unsubscribe link into a text module. The image it references as an example is missing.

Technical details:

  • sendgrid-python Version: 5.6.0
  • Python Version: 3.6.2

bridger avatar Nov 11 '18 19:11 bridger

Hello @bridger,

Thanks for submitting a GitHub issue! We are very sorry that you are running into this problem. In order to better serve you, as this does not present itself as a library specific issue, we would like to ask that you reach out to our support team at https://support.sendgrid.com.

Thank you!

SendGrid DX Team

thinkingserious avatar Nov 18 '18 15:11 thinkingserious

For future people who might have the same issue I was able to workaround it.

  1. Download/export the template as html
  2. Replace the [Sender_Name] with {{Sender_Name}}, etc.
  3. Re-import the template

Now you can use the templates but they use the correct replacement tags. You can fill in the Sender_Name field with the dynamic_template_data parameters for sending mail.

bridger avatar Nov 30 '18 04:11 bridger

It seems like this should be reopened. This seems like a major bug in SendGrid templates - the "Unsubscribe Module" is mandatory, and yet, it doesn't work. It just keeps sending out unprofessional [Sender_Name] [Sender_Address], [Sender_City], [Sender_State] [Sender_Zip] Unsubscribe - Unsubscribe Preferences" as-is with nothing filled in and nothing linked.

The Unsubscribe Module is broken and needs to be fixed.

b9chris avatar Mar 07 '19 20:03 b9chris

It seems like this should be reopened. This seems like a major bug in SendGrid templates - the "Unsubscribe Module" is mandatory, and yet, it doesn't work. It just keeps sending out unprofessional [Sender_Name] [Sender_Address], [Sender_City], [Sender_State] [Sender_Zip] Unsubscribe - Unsubscribe Preferences" as-is with nothing filled in and nothing linked.

The Unsubscribe Module is broken and needs to be fixed.

Second! This needs to be fixed. Exporting/Importing to workaround is not an acceptable solution.

tysonholub avatar Mar 11 '19 22:03 tysonholub

Hello @bridger,

Thanks for submitting a GitHub issue! We are very sorry that you are running into this problem. In order to better serve you, as this does not present itself as a library specific issue, we would like to ask that you reach out to our support team at https://support.sendgrid.com.

Thank you!

SendGrid DX Team

I don't particularly care for this response.

Regardless of whether the python helper classes are coded correctly or not this is an engineering issue at Sendgrid and as such we should not be tasked with passing this along to support to inform them API is not functioning correctly.

That is in fact the job of the Sendgrid employees maintaining this lib or those moderating these support issues.

Please pass this thread along to your colleagues as it's not the responsibility of paying customers to communicate issues between departments.

This thread alone probably documents the issue well enough to inform the Sendgrid engineers working on this where the problems exist in the codebase.

Also, this functionality is still broken at the time of writing this comment.

HayesData avatar Apr 06 '19 10:04 HayesData

Also having this issue which I believe it is based on a lack of documentation and possible bug. So the transactional template has the [Sender_Name] tags which are for the Marketing campaigns as seen here: https://sendgrid.com/docs/ui/sending-email/senders/#before-you-begin

I have tried using the same Sender email as the from in the transactional email in the API and still those are not replaced.

So either a new module is needed for the transactional emails or a new prop like senderId is needed in the object so we can choose the sender. I rather have the latter.

sfratini avatar Apr 11 '19 10:04 sfratini

Yeah. Total mess, and only made worse by a spaghetti bowl of confusing docs.

simplecircle avatar May 05 '19 15:05 simplecircle

That {{ }} instead of [] solved the issue. You guys should change this in the documentation and also in the default template creation. It is pain in the a$$

dssagar93 avatar May 07 '19 12:05 dssagar93

+1 I don't think is so hard to change [] for {{}} for the sendGrid team. Having to export html, modify and import is not a good solution!

jcatalaamat avatar May 24 '19 17:05 jcatalaamat

Hi, as mentioned in #809 I vote for this issue to be progressed, including the definition of a footer 'Mail Helper Class' The current footer management steps are not clear. I'd also support for a better documentation of current workaround.

Nicosan-K avatar Jun 11 '19 23:06 Nicosan-K

I'm new to SendGrid and this was completely throwing me off so I'm glad I found this ticket. I was kind of expecting the [Sender_%] values within the unsubscribe widget to be pulled from the "Sender Management" section of the SendGrid interface, although from a programming perspective I'm guessing each sender listed in that section would need to have a "sender ID" generated much like the template IDs have so that we can reference the appropriate sender data within the JSON object. For now I'll be using the import/export hack but would much prefer a prettier solution; one that uses the actual sender information within SendGrid.

edit: having the [Sender_%] data default to a "default" sender if we don't specify a sender ID would be nice, too

dustinfl avatar Jun 12 '19 18:06 dustinfl

Thanks for taking the time to detail your thoughts and suggestions @dustinfl! Your comment adds to the priority of this issue, so thanks again!

thinkingserious avatar Jun 13 '19 17:06 thinkingserious

The issue is compounded if you are using Design template instead of Code template. Since the workaround requires you to use the Code template editor (export/import).

celwell avatar Jun 24 '19 17:06 celwell

I'm deeply impressed by how any developer can think it's ok any feature to be that confusing and messed. Sometimes I just wonder, what the actual fuck. lol

astutejoe avatar Jul 05 '19 19:07 astutejoe

I am able to use the workaround to render the proper sender name into my emails. However, in order to use the unsubscribe module, I need to keep the version with the [] placeholder in, which looks ugly.

Is there a way to either fix it properly or just remove the [sender_name] entirely from the unsubscribe block and just keep the links there?

taschik avatar Jul 07 '19 20:07 taschik

Ran into this problem myself, and the way it's currently addressed in the Unsubscribe Plugin is via "Sender Management". As I have not seen this information on this thread but Google led me here, I will post the help document links here: https://sendgrid.com/docs/ui/sending-email/senders/#adding-a-sender

Their idea is that you will add senders to the list here: https://mc.sendgrid.com/senders/new

twocs avatar Jul 08 '19 05:07 twocs

@twocs Great ! and how do you configure this sender info in dynamic templates unsubscribe modules ? This is so confusing.

kofronpi avatar Jul 17 '19 12:07 kofronpi

@twocs Great ! and how do you configure this sender info in dynamic templates unsubscribe modules ? This is so confusing.

The way that is shown at https://github.com/sendgrid/sendgrid-python/issues/735#issuecomment-443089317 is to use the template

{{Sender_Name}}

Dynamic field data is passed as a parameter. If sending as json it is in a section such as:

"dynamic_template_data": { "Sender_Name" : "konfronpi" }

So basically, some anti-spam laws say that we must provide certain details with marketing emails. SendGrid intends that sender info is set for the account as [Sender_Name] via the Sender's list https://mc.sendgrid.com/senders/new.

We can also achieve this via dynamic templates by using {{Sender_Name}} if programmatically specifying this data at send time.

twocs avatar Jul 17 '19 13:07 twocs

@twocs thanks that's interesting ! Can you configure unsubscribe groups links as well ?

kofronpi avatar Jul 17 '19 13:07 kofronpi

On Wed, Jul 17, 2019 at 9:47 AM Tom Anderson [email protected] wrote:

@twocs https://github.com/twocs Great ! and how do you configure this sender info in dynamic templates unsubscribe modules ? This is so confusing.

The way that is shown at #735 (comment) https://github.com/sendgrid/sendgrid-python/issues/735#issuecomment-443089317 is to use the template

{{Sender_Name}}

Dynamic field data is passed as a parameter. If sending as json it is in a section such as:

"dynamic_template_data": { "Sender_Name" : "konfronpi" }

So basically, some anti-spam laws say that we must provide certain details with marketing emails. SendGrid intends that sender info is set for the account as [Sender_Name] but we can also achieve this via dynamic templates by using {{Sender_Name}} if we are programmatically specifying this data

This is a little misleading. What does not work, is this template, or any template, as it was intended to work.

What also does not work is use of:

[Sender_Name]

In Dynamic Templates that's ignored, and emitted literally ("[Sender_Name]" goes out in every email, to actual customers).

What does work is this complicated workaround:

  1. Switch each of those to anything you like - {{Sender_Name}} if you want, but you could also use {{Unsubscribe.senderName}} or even {{Jello}} if you wanted, it doesn't matter because the framework has no actual support for this section.

  2. Emit the Unsubscribe field info in each of your JSON packets you send to these Dynamic Templates. This is why I proposed {{Unsubscribe.senderName}} above - you could include a .Unsubscribe property in each JSON you emit to SendGrid.

Of course, if the JSON you're sending is used elsewhere in the system - for example, info about an event that needs to be emitted over email - you've now got a problem on your hands. Any other use in the system doesn't need Unsubscribe info. So you'll have to put a SendGridWrapper of some sort around the data, add that Unsubscribe property to it, and take it from there.

In the end, this is all a lot of unnecessary complexity. This template system is simply broken. The default Unsubscribe module should simply work, taking its info from the central settings in SendGrid. There is no way to get that info from those central settings today, and the default templates new users start with lead them down this rabbit hole, probably to this thread.

b9chris avatar Jul 17 '19 14:07 b9chris