Send Newly Transformed Data via Email

In this use case, we will cover a scenario where, if a user creates a new entry in Contentstack, Automations should be able to transform the input data as per the transform modifier. You can use different transform modifiers such as camelCase, capitalize etc., to modify your final output.

Let's break this scenario to see what must be the trigger event and the consequent action required to execute the Automation:

  • Set Up the Contentstack “New Entry” Trigger Event: This trigger event is activated whenever a user creates a new entry for a particular stack, and in turn, it activates the Automation.
  • Set Up the Transform Action: Once the above event triggers the Automations, it will modify the JSON code passed in the transformation box.
  • Set Up the Email By Automations “Email By Automations” Action: Once the Transform action is completed, you can post the transformed JSON data to Email By Automations.

Let’s look at the setup in detail.

  1. Create an Automation

    To create an automation, perform the steps given below:

    1. Log in to your Contentstack account and click the “Automation Hub” icon.
    2. Click + New Project and provide the required details to create a new project.
    3. Click + New Automation to add the steps required to configure automation.

    Next, let’s look at the steps to set up the trigger event.

  2. Set up the Contentstack Trigger Event

    1. Click Configure Trigger and select the Contentstack connector.
      Select-Contentstack-Trigger.png
    2. Add your Contentstack account. For more information, refer to the Contentstack Trigger documentation.
    3. Once done, select New Entry from the list of trigger events and define the rest of the steps needed to set up the trigger (refer steps 3 to 10 in Contentstack Trigger).
      Configure-Contentstack-Trigger.png
    4. Click Test Trigger to execute and test the trigger that you configured.
  3. Set up your Transform Action Connector

    Let’s configure the Transform action connector.

    1. In the Configure Action section, click the Transform connector.
      Select-Transform-Action-Connector.png
    2. Select the Transform action.
      Select-Action.png
    3. Click Add Input, and enter a variable name for the Input Name (say, “name”) and an Input Value for the variable (say, “john” in lowercase letters) (see screenshot in next step).
    4. Note: You can even pass the value directly into the Transformation box.

    5. Let’s enter the JSON code that uses the “capitalize()” modifier in the Transformation box. Use the following code:{“result” : “{capitalize(name)}” }
    6. Configure-Transform-Action.png

      Note: You can use the data received from the trigger instead of manually adding the values.

    7. Click Proceed.
    8. Click Test Action to execute the JSON code.
      Test-Action.png
    9. You should see the output with the first letter capitalized. Click Save and Exit for the Transform process flow.
      Save-Exit.png

    This sets the Transform action connector.

  4. Test the Automation

    Now, let’s see how you can test out your Automation. To do so, perform the steps given below:

    1. Go to Contentstack and create an entry for the content type that you selected in your trigger event in Step 2.
      This should trigger your Automation.
    2. Let’s see how to post the JSON data by sending an email through the Email By Automations action connector.
      1. In the Configure Action section, click the Email By Automations connector.
        Select-Connector.png
      2. Select the Send Email action.
        Select-An-Action.png
      3. In the Configure Action tab, enter the following details:
        1. Email address of the recipient
        2. The Subject for the email.
        3. Under the Body Type field, enter the type.
        4. Add the email content within the Body field.
        5. Additionally you can add optional fields such as the “CC” and “BCC” email addresses.
        6. Note: You can use the output from the transform action and send it to your email.

          Email-By-Automations.png

      4. Click Proceed.
      5. To execute and test the configured action, click Test Action.
        Test-Action.png
      6. The email is queued and sent to the recipient’s email address. Click Save and Exit.
        Save-Exit-Button.png
      7. To check the email, navigate to your inbox.
        OutpUt.png

Was this article helpful?

Thanks for your feedbackSmile-icon

On This Page

^