Template Strings

How to make Streamscript templates in flow using the backtick ` character, referencing merge fields, flow resources and global variables (according to ChatGPT)

 


 

Transcript:

 

Intro

For the first step, I'm going to add a Streamscript template.

A template lets us mix text and data together. We can put variables or merge fields inside it without having to concatenate strings and so on.

 

 

Writing an email body template

Now for the twist. Let's ask ChatGPT to compose a template. I prepared this prompt for ChatGPT: "Please write me a Streamscript. It should return just the email body template that I can use to welcome new leads." ChatGPT has limited access to information after 2021, so it doesn't know about Streamscript. So let's teach it using the Streamscript tutorial. I'll copy the tutorial over from the Streamscript website, and then I'll paste that tutorial text below the prompt.

 

Backtick start and end

For context, let's see what ChatGPT comes up with.

 

It used the dollar sign to represent the $Lead variable, and it used the global $Organization variable for the company. I'm going to copy this template onto my clipboard and paste it directly into the Streamscript step

 

 

Using the $Record global

Well, it looks like we have a slight snag. The lead should be called $Record for a record triggered Flow, and we'll also reference the FirstName field straight after that.

Looks good. I'll create a Send Email action to complete the process.

 

Access the Text output

I'll use the template as a body of the email and set a cheery subject line.

To finish off I'll select the email address from the record trigger as the recipient.  Click done. Click Save. We'll name this flow Welcome Email to try it out.

 

Check the merge fields

I'll activate the flow, and then I'll create a new lead in the system. First name, last name, company, email, I'll click Save to create the lead and fire the record triggered flow.

And there is the welcome email.

The template contains the recipient name, and the organization fields look too.

 

 

Summary

So summing up. We had a requirement to send welcome emails to Leads using a template. We asked ChatGPT to compose a template in Streamscript, and we supplied Streamscript syntax to assist with that. This basic workflow can be tested quickly with many other scenarios.

 

 

 

Getting started with Streamscript
Install from the Salesforce AppExchange
Package install link: /packaging/installPackage.apexp?p0=04tGA000005ZGcU