Strange behaviour from SendGrid

Hey @JustinC,

You can set up to 40 variables with the Send emails with SendGrid plugin, give that a go! :slightly_smiling_face:

1 Like

Hey Salar,

I’ve recently noticed that quotation marks are also not accepted in the Sendgrid plugin. Do you have a regex pattern to replace ["] with [’] ?

Greg

(\") would be the regex pattern, and in the replace field enter your single apostrophe or '

https://regex101.com/ and other tools like it can be helpful in quickly testing javascript regex

2 Likes

Hey @gregjohnkeegan,

Looks like @philip beat us to the punch there. We haven’t made any changes to the plugin, but we’ll follow up with SendGrid to see if there’s something new from their side.

There’s a few of us at CoBubble, so tagging us by @cobubble helps us get notified right away. :slight_smile:

2 Likes

Low five. Good man.

@gregjohnkeegan Ran into this as well a few weeks ago. Been sending out emails with a simple find and replace, no regex:

Lol, so much easier - don’t use a regex pattern.

I was struggling with this and this worked, However, it ONLY works on Development, but when i try the Exact same thing on Live, it gives the following error:

Raw error from SendGrid API - Send email: {“errors”:[{“message”:“Bad Request”,“field”:null,“help”:null}]}

And the really weird thing is that here’s what I’m getting (this is the troubleshooting sequence i tried):

  1. Simply Display list (it will output with commas by default from Bubble) - Works on Development

  2. Joining with line_break does NOT work on Development (expected result as per this conversation thread)

  3. Adding regex find&replace and replacing \n with
    DOES work on Development (as per discussion above)

  4. Deployed to Live - Same exact expression does NOT work on Live (Ok, so something appeared wrong here - I tried to simplify it…)

  5. Display Simple List (as in #1), WITHOUT line_break, FAILS on Live - gives the following error (same as above error):

Raw error from SendGrid API - Send email: {“errors”:[{“message”:“Bad Request”,“field”:null,“help”:null}]}

Any ideas? (thanks in advance)

2 Likes

Hello,

I’m trying to schedule api workflows to send emails at certain times during a month, so i need to use lists as they are via a ‘do a search for’. I can’t use a element from a page.

So after reading this thread i found that nothing fit my scenario. I reached out to Sendgrid and they responded with this:

Whenever you’re passing HTML code to us such as the < br > , the replacement tag in the template needs to be added with 3 curly braces instead of 2.

Basically, you need to have {{{content}}} in the template itself and a parameter that will pass on the actual content. Normally, the content is passed with the "dynamic_template_data" object like so:

```

"dynamic_template_data":

{

"content":"jim<br>bob</br> and so on in your case"

}

```

I think that will be done through the use of the PHP library, because it implies doing an API call and add the "dynamic_template_data" object.

_Please check out this documentation in order to get familiar with the syntax: https://sendgrid.com/docs/User_Guide/Transactional_Templates/Using_handlebars.html_

this didn’t work for me either. I actually couldn’t get ANY html to be rendered properly in emails.

Running out of avenues to look into here… has anyone figured this out?

Here’s what i found when i went into gmail to inspect html that was actually being displayed &amp; i found out that the &amp;'s were being turned into &amp;lt; (see below )

@copilot any advice on how to work with or around this?

Lists are a crucial part of my email mission with my app and i can’t just make x amount of variables or &quot;substitution tags&quot; to input a list line by line because I’m sending lists by categories and items within the category

Here’s what I was planning:

image

This works for me because each category will only take up 2 tags and it handles variations 1000xs better.

Please help!!:disappointed_relieved::sob:

Well it turns out I was making one very simple mistake.

The values that you are sending to sendgrid need to be in an HTML section…


…but honestly I’m 99.99999 sure I was doing that the whole time.
Guess not.

Moral of the story: double check EVERYTHING.

1 Like

I tried this, but it isn’t working for me.

1 Like

Hi All,

I figure this was relevant after spending some time trying to fix it. I was having a problem where when I would send a single apostrophe " ’ " in the subject Sendgrid would send it out as " ’ ". It was not affecting any text in the body of my email only the subject. I was able to solve this by adding 3 brackets in Sendgrid for the subject tag instead of two. So in Sendgrid my subject field looks like {{{subject}}}.

If you are passing not string value then SendGrid will give you :point_down:

{“errors”:[{“message”:“Bad Request”,“field”:null,“help”:null}]}

Convert your all non-string value to string before sending to template file.

Happy Coding :blush:

1 Like

Here is what worked for me. I had all my list items in a state and sending the state itself to the Copilot sendgrid plugin would not work if you wish to display a list.

What i had to do was to push the list to the database (which in hindsight was a good decision). In the same workflow I retrieved the list as a text from the database field and uses the :Find and Replace function to repalce the line break \n with a
.

Once that was done all i had to do in Sendgrid was to use the 3 curly brackets to display each string in its own line. {{{data}}}

hope this helps someone. I burned a fair bit of time to figure this out. :slight_smile:

image
image

Life saver!! This worked like a charm. Inputing it as @funwtp showed below. :pray:t5: