Table of Contents

Journey integration for Email sends

Manish Manohar Updated by Manish Manohar

We’ll deploy a script that automatically sends an email to the user when triggered.

Steps to Create & Deploy Google Apps Script Email Web App:

  1. Open Apps Script Home
    Go to 👉 https://script.google.com/home
    Make sure you’re logged into your Google account.
  2. Create a New Project
  • Click on + New Project
  • A blank editor will open.
  • Click on “Untitled project” (top-left) and give it a meaningful name.
  1. Paste Your Script
  • Copy this provided script
    Please update the username and password.
    These can be anything you choose — they are not linked to your email ID or account. This step is only for added security.
    function doPost(e) {
    try {
    // Parse incoming JSON
    const data = JSON.parse(e.postData.contents);


    // Hardcoded credentials
    const USERNAME = "myuser";
    const PASSWORD = "mypassword";


    // Check credentials
    if (data.username !== USERNAME || data.password !== PASSWORD) {
    return ContentService
    .createTextOutput(JSON.stringify({
    status: "error",
    message: "Unauthorized"
    }))
    .setMimeType(ContentService.MimeType.JSON);
    }


    // Send email if authorized
    GmailApp.sendEmail(
    data.to,
    data.subject,
    data.message
    );


    return ContentService
    .createTextOutput(JSON.stringify({
    status: "success",
    sentTo: data.to
    }))
    .setMimeType(ContentService.MimeType.JSON);


    } catch (err) {
    return ContentService
    .createTextOutput(JSON.stringify({
    status: "error",
    message: err.message
    }))
    .setMimeType(ContentService.MimeType.JSON);
    }
    }
  • In the editor, paste it inside the Code.gs file (replace any default code).
  1. Deploy the Script as a Web App
  • Click the Deploy button (top right).
  • Select “New deployment”.
  • In the dialog, click the gear icon (⚙️) under “Select type” → choose “Web app”.
  1. Configure Deployment
  • Description: Add something meaningful (e.g., “Diabetes Quiz API”).
  • Execute as: Choose “Me” (your email).
  • Who has access: Select “Anyone” (⚠️ means public access — be cautious).
    ⚠️ Important Security Note: When you set “Who has access” to Anyone, the script can be accessed publicly by anyone with the link. If sensitive data is involved, consider restricting access to “Anyone with Google Account” or specific users.
  1. Authorize the Script
  • First-time deployment will ask for Google Account consent.
  • Read the permissions carefully. Click Allow if you’re comfortable with the risks.
  1. Get Your Web App URL
  • After deployment, you’ll get a Web App URL.
  • Copy and save it — this is the endpoint you’ll use to call your script.
  1. Create a new journey in Turn.
    The following card will send an email using the Google Apps Script service.

To make it work, you’ll need to provide the API URL, your username and password, the recipient’s email address, the subject line, and the message body.

card SendEmail do 
response =
post("<URL that was copied from app script>",
timeout: 5_000,
body: """
{
"username": "myuser",
"password": "mypassword",
"to": "<recipient Email>",
"subject": "Alert from Turn",
"message": "You have received a "
}
""",
headers: [["Content-Type", "application/json"]]
)

log("@response")
end

Was this article helpful?

How can I export data from Turn?

Contact