cs-icon.svg

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 “Entry Created” 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 Automate “Email by Automate” Action: Once the Transform action is completed, you can post the transformed JSON data to Email by Automate.

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 “Automate” 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 from the left navigation panel.
      Click_Configure_Trigger
    2. Within the Configure Trigger step, click the Contentstack connector.
      Select_the_Trigger.png
    3. Add your Contentstack account. For more information, refer to the Contentstack Trigger documentation.
    4. Once done, select Entry Created from the list of trigger events and define the rest of the steps needed to set up the trigger (refer steps 3 to 12 in Contentstack Trigger).Select-Event-Stack.png
    5. 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. Click Configure Action Step from the left navigation panel.
      Click-Configure-Action-Step.png
    2. Click Action Step to configure third-party services.
      Select_Action_Step
    3. Within the Configure Action Step, click the Transform connector.

      Note: You can sort and search the connector(s) based on the filter.

      Select_the_Transform_Connector.png
    4. Select the Transform action.
      Select-Transform-Action.png
    5. 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).

      Note: You can even pass the value directly into the Transformation box.

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

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

      Select-Transform-Fields.png
    7. Click Proceed.
    8. Click Test Action to execute the JSON code.
      Test-Transform-Action.png
    9. You should see the output with the first letter capitalized. Click Save and Exit for the Transform process flow.
      Save-Exit-Transform.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. To post the JSON data by sending an email through the Email by Automate action connector:
      1. Click + Add New Step. Click Action Step to configure third-party services.
      2. Within the Configure Action Step, click the Email by Automate connector.
        Select_the_Email_by_Automation_Hub_Connector.png
      3. Select the Email by Automate action.
        Select-Email-Action.png
      4. 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.

          Note: You can use the output from the transform action and send it to your email.

          Select-Email-Fields.png
      5. Click Proceed.
      6. To execute and test the configured action, click Test Action.
        Test-Action-Email.png
      7. The email is queued and sent to the recipient’s email address. Click Save and Exit.
        Save-Exit-Email.png
      8. To check the email, navigate to your inbox.
        Email-Output.png
Was this article helpful?
^