Skip to main content
All CollectionsService ManagementCases
Sending a Google Review Link Based on Customer Feedback
Sending a Google Review Link Based on Customer Feedback
Nick Kewney avatar
Written by Nick Kewney
Updated over a month ago

If you’re looking to encourage happy customers to leave a review on Google, you can automate this process in The Layer using functions. By setting up a function that triggers an email with a Google review link whenever positive feedback is received, you can streamline the process and increase the likelihood of valuable reviews.

Setting Up the Function to Trigger a Google Review Link

Using Layer’s scriptable functions, you can create a function that will monitor feedback scores and automatically send a Google review link to customers who provide high ratings. Here’s a step-by-step guide.

Step 1: Obtain Your Google Place ID

To create a direct link to your Google review page:

  1. Enter your business name and address.

  2. Copy the Place ID for your business.

Step 2: Build the Review Link

Once you have your Place ID, you can construct the review link using this format:

https://search.google.com/local/writereview?placeid=YOUR_PLACE_ID

Replace YOUR_PLACE_ID with your actual Place ID. This link will direct users to your business’s Google review page.

Step 3: Create a Scriptable Function in Layer

Now, it’s time to set up a function in Layer to track feedback scores and trigger the email. Below is an example of how you can set up this function to work with feedback:

Check Feedback Rating:

If the feedback starId is equal to 5 stars (starId=1), proceed.

Set Review Link

Define placeID with your Google Place ID.
Construct reviewLink using placeID.

Retrieve Customer Email

Use caseId to look up the customer’s email address (assume a function like getCustomerEmailByCaseId exists)

Compose Email Content

Draft the email message, incorporating reviewLink to direct the customer to Google Reviews.

Send Email

Use an email function to send the message, setting the subject and body.

e.g.

var _payload = JSON.parse(payload);

var starId = _payload.StarId;
var caseId = _payload.CaseId;

// Check if StarId is 1 and email is not null
if (starId === 1) {
var placeId = "$$place_id";
var reviewLink = "<a href='https://search.google.com/local/writereview?placeid=" + placeId + "'>Click here!</a>";
var mailer = new ScriptableFunctionMailer();

// Step 1: Set up the API Request
var request = new ScriptableFunctionHttpRequest();

// Step 2: Authenticate
request.AddHeader("Token1", "$$token_1[Token 1 from your API Application Tokens]$$");
request.AddHeader("Token2", "$$token_2[Token 2 from your API Application Tokens]$$");

// Step 3: Fetch the Case data
var selectedCase = JSON.parse(request.Get('https://webapi.thelayer.com/', 'api/Cases/Cases/' + caseId, 'application/json'));

// Ensure email and its parent exist to prevent null reference errors
var recipientEmail = selectedCase.Contact && selectedCase.Contact.Email;
if (recipientEmail) {
mailer.CompanyId = companyId;
mailer.Subject = "We’d Love to Hear Your Feedback!";
mailer.Body = "Hello,<br><br>We hope you had a positive experience with us! If you have a moment, we’d greatly appreciate your feedback.<br><br>" + reviewLink + "<br><br>Thank you for choosing us!<br>Best Regards,<br>$$company_name$$";
mailer.Recipients = recipientEmail;
mailer.HasBranding = true;
//mailer.MailAgentId = 1234;
mailer.Send();
} else {
return "Email not found. Cannot send.";
}
} else {
return "StarId is not 1. No email sent.";
}

return "OK";

Replace "YOUR_PLACE_ID" with the actual Place ID you obtained earlier.

You then need to map that script here.

Step 4: Test and Enable the Function

Make sure to test the function by submitting a feedback score of 5 and verifying that the email with the Google review link is sent to the specified customer email. Adjust the email content as needed to match your branding.

Did this answer your question?