SOLVED

Escaping braces (curly brackets) in text tokens for use in webhooks?

Go to solution
peter_fedewa1
Level 2

Escaping braces (curly brackets) in text tokens for use in webhooks?

Hey all,

 

I am running into an issue with a webhook that triggers an SMS message through a third party vendor we are using. 

 

The vendor we are using stores some personalization information that we populate when a customer opts in. These fields can be used to create dynamic SMS messages. The problem I am running into when sending messages that are triggered through Marketo automations is that the vendor also uses {{variable_name}} format for their personalization tokens. So, when I send an API POST request to trigger a message, the SMS tool variables get removed when Marketo tries to resolve them in the text token. 

 

This appears to work fine for Marketo fields, which was a kind of happy surprise since I'd never tried to use them in a text token (if anyone can tell me if this is super dangerous, I'd appreciate it). But, because of how our systems are scaled currently, there's some data that doesn't live in Marketo effectively but is in the 3rd-party SMS tool.

 

So the following will render the first name just fine in the message but the other variable (account manager in this case) gets wiped out for obvious reasons.

Screenshot 2024-09-12 at 12.12.35 PM.png

That's a lot of preamble for: is there a way to escape the braces on the second variable so the system receiving the POST request will get the full {{var8|your account manager}} as part of the payload?

 

I tried rich text with the <span> trick outlined in @SanfordWhiteman's "Displaying literal curly braces {{ }} in Marketo" article but the spans actually ended up rendering out as part of the copy in the SMS message.

 

One other note, the POST requests in this case are URL encoded and not JSON.

Example of the webhook I am usingExample of the webhook I am using

 

Thanks for any ideas!

- Peter
Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Escaping braces (curly brackets) in text tokens for use in webhooks?

Quite a bind here. Only workaround I can think of is pre-URL-encoding the {{my.token}} content and set encoding to None in the webhook definition.

View solution in original post

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Re: Escaping braces (curly brackets) in text tokens for use in webhooks?

Quite a bind here. Only workaround I can think of is pre-URL-encoding the {{my.token}} content and set encoding to None in the webhook definition.

peter_fedewa1
Level 2

Re: Escaping braces (curly brackets) in text tokens for use in webhooks?

Worth a try. I will see how it goes and report back.

- Peter
peter_fedewa1
Level 2

Re: Escaping braces (curly brackets) in text tokens for use in webhooks?

Thanks, @SanfordWhiteman. It's not the prettiest so I would limit this method to my more experienced users only but it worked.

 

Request encoding is set to "None." I didn't change anything else in the webhook setup. Then "manually" encoded the text for the message body token except for the Marketo first name field:

 

Hi.%20This%20message%20is%20for%20{{lead.First Name}}%20from%20%7B%7Bvar8%7Cyour%20account%20manager%7D%7D.

 

 The response from the the POST endpoint:

"body":"Hi. This message is for Peter from {{var8|your account manager}}."

 

The message finally rendered:

Screenshot_20240913-135109.png

 

"Peter" is from Marketo. "John" is from the SMS tool's data set.

- Peter
SanfordWhiteman
Level 10 - Community Moderator

Re: Escaping braces (curly brackets) in text tokens for use in webhooks?

This leaves one gap, though. If there are characters within the {{lead.First Name}} that must be URL-encoded, that’ll break the payload. Your back end may not care if you send an IRI (i.e. include non-ASCII characters in the URI). But it would definitely care if you included a literal & or +, even if those are infrequently found in First Names!