How do I send a confirmation email with a unique code? | Community
Skip to main content
Stephen_Moore
New Participant
February 16, 2022
Solved

How do I send a confirmation email with a unique code?

  • February 16, 2022
  • 2 replies
  • 6373 views

Hi,

So there is an upcoming tradeshow and we are giving out free passes to people who submit the form.

There are a limited number of passes, and the pass codes have been provided to us.

I am searching for a way to automatically send out these confirmation emails with the unique codes embedded in the emails.

I also need to know when we have exhausted the codes that we have.

I tried looking on the Nation, but didn't see a solution.

Thanks,

Stephen

Best answer by SanfordWhiteman

  1. Create a custom text {{my.passcode}} token local to your program (add a placeholder default value as the token value)
  2. ...

This is a little development heavy method and you'll definitely need a technical person to pull this off. I'll let Sandy confirm if there's a comparatively less dev heavy/easier solution to pull this off! 🙂 Thank you.


Hm. That sounds far too complex. You need to keep a pointer to the most recent code on the stack, which means a separate database. And you need a separate web app to call the REST API!

 

You want to avoid both REST API calls and any (trivially hackable) calls made from the form. All logic should be initiated on the Marketo server side.

 

The better way to do this is via a webhook-compatible service. It shares some of the general logic above. But you can store the codes in a simple text file in Design Studio. Then each time the webhook is called, you increment the pointer by 1 and get the Nth line in the file. Return that in the webhook: done.

 

I’ve done this a bunch of times and if you search my past posts you’ll get some pointers. It’s like < 10 lines of code.

 

Easier still is to “reverse the charges”: have Marketo generate the unique code, then call an external service to say “Hey, I assigned such-and-such code to the lead with this email address.” You can generate an acceptably unique code by mixing together the person’s Marketo Unique Code with the Program ID. The end user will not be able to guess this.

2 replies

Darshil_Shah1
Community Manager
February 16, 2022

Off the top of my head, here's what you can do -

  1. Create a custom text {{my.passcode}} token local to your program (add a placeholder default value as the token value).
  2. Create an email, plug the {{my.passcode}} token where you want to display the passcode in the email.
  3. Create a trigger campaign with Campaign is Requested trigger source "Web Service API".
  4. In the flow of the campaign use the Send Email flow step to send the email.
  5. You'll need to customize the form submission action to execute below steps, 6 & 7 or built a web-service to do so.
  6. You can choose to store the pass-codes in a stack, and use AJAX calls to query off the pass-code from the top of the stack for each form fill. Make sure you remove the top code after each query to ensure you have un-used pass-code for the next person filling out the form.
  7. Asynchronously call the request Trigger campaign endpoint and each time supply the unique pass code value for the {{my.passcode}} token in the POST request body (the one you got after querying the stack in step 6).
  8. Depending on the platform you choose to store/manage your stack, you can see if a custom alert email can be configured to let you know when the stack gets emptied.

This is a little development heavy method and you'll definitely need a technical person to pull this off. I'll let Sandy confirm if there's a comparatively less dev heavy/easier solution to pull this off! 🙂 Thank you.

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
February 16, 2022

  1. Create a custom text {{my.passcode}} token local to your program (add a placeholder default value as the token value)
  2. ...

This is a little development heavy method and you'll definitely need a technical person to pull this off. I'll let Sandy confirm if there's a comparatively less dev heavy/easier solution to pull this off! 🙂 Thank you.


Hm. That sounds far too complex. You need to keep a pointer to the most recent code on the stack, which means a separate database. And you need a separate web app to call the REST API!

 

You want to avoid both REST API calls and any (trivially hackable) calls made from the form. All logic should be initiated on the Marketo server side.

 

The better way to do this is via a webhook-compatible service. It shares some of the general logic above. But you can store the codes in a simple text file in Design Studio. Then each time the webhook is called, you increment the pointer by 1 and get the Nth line in the file. Return that in the webhook: done.

 

I’ve done this a bunch of times and if you search my past posts you’ll get some pointers. It’s like < 10 lines of code.

 

Easier still is to “reverse the charges”: have Marketo generate the unique code, then call an external service to say “Hey, I assigned such-and-such code to the lead with this email address.” You can generate an acceptably unique code by mixing together the person’s Marketo Unique Code with the Program ID. The end user will not be able to guess this.

Jo_Pitts1
Community Manager
February 16, 2022

@stephen_moore,

if you must use pre-determined codes, then go with @sanfordwhiteman's approach.  A great option for the webhook compatible service he's talking about is flowboost.  Sanford didn't mention it as he wrote it.

 

cheers

Jo

SanfordWhiteman
New Participant
February 16, 2022

I am searching for a way to automatically send out these confirmation emails with the unique codes embedded in the emails.

To be clear, you have a stack of unique codes (not preassigned) and you want to pull a new code off the stack whenever somebody submits the form, assigning it to that lead?

Stephen_Moore
New Participant
February 16, 2022


To be clear, you have a stack of unique codes (not preassigned) and you want to pull a new code off the stack whenever somebody submits the form, assigning it to that lead?


Yes, that is correct.
I have a list of codes and need to assign them when the form is submitted.