If Condition using OR operator

Using the IF condition in Quickwork. Quickwork is a no-code, API-based SaaS platform with pre-integrated apps to automate business workflows.

Quickwork has developed a cutting edge for If Condition by introducing OR and AND operators. Using this, the If Condition can be used n number of times within a journey. Also, the precision of conditional validation gets increased as OR/AND imposes its own set of protocols for validating the data to pass through the actions in a journey:

  • OR: The OR operator allows the data to process further when atleast one of the specified conditions is true. The execution of the journey stops only when the input data does not satisfy any of the specified conditions.

  • AND: The AND operator allows the data to process further only when all of the specified conditions are true. If any of the conditions is false, i.e. do not match with the input data, the execution of a journey breaks down immediately.

Use case

Let's consider a business use case to understand OR/AND in a more realistic way.

Add a new task to Asana whenever the support team receives escalation emails from the customers on Gmail. Also, acknowledge the customers with the confirmation email on receiving the escalation.

  • Trigger: Gmail-Get email

  • Condition: If condition with OR/AND functionality

  • Action: Asana- Create task, Gmail - Send email

Prerequisites

Before configuring a journey, create an Asana account with a workspace, project, and team members added to it.

Configuring a trigger

The following steps will help you configure the Gmail account on which you'll be receiving emails from the customers. Please connect the official support team's Google account for a better experience:

  1. Under the Event section, search for the Gmail app in the Apps list under the New Trigger option.

  2. Then select the trigger event, Get email, from the Triggers list.

  3. Authorize Gmail by selecting an existing connection from the drop-down or creating a new connection.

  4. Select the INBOX label from the drop-down menu in the Label field:

Figure 1: The Gmail trigger

Categorizing the emails

Probability is the support team receives numerous emails daily from the customers i.e., thankful emails, acknowledge emails, account activation, deletion emails, and much more. So, we need to filter the emails based on their subject lines and capture those emails that are related to product issues and escalations. Later, convert those emails into tasks and assign them to the developer team to look into it.

To categorize, consider keywords such as Escalation, Issues, and Errors that are most likely to arrive in the email subject line. Then, apply the If Condition on the same.

As per the business requirement, you can figure out more keywords for convenience.

Adding If Condition

Now, let's use the If Condition feature. Under the Steps section, click the Business Logic option and select If Condition:

Figure 2: The If Condition

Now let's start configuring the If Condition:

  1. Inside the Setup If condition block, pass the Subject data pill as an output to the Left Value field from the output of the Get email trigger under the Data Tree Output.

  2. Select the condition as Contains in the Condition field.

  3. In the Right Value field, specify the subject line keyword Escalation as a value:

Figure 3: Applying If Condition on the "Escalation" keyword

Adding an OR operator within If Condition

As per the keywords categorized for the email subject line previously, let's use the OR operator within the If condition. The remaining keywords left for conditional validation are Issues and Errors. Click the Add condition button at the bottom of the If Condition block and select the OR operator:

Figure 4: Using the OR operator

The second If condition block will open up:

  1. In the Left Value field, pass the Subject data pill from the output of the Get email trigger under the Data Tree Output.

  2. Select the condition as Contains in the Condition field.

  3. In the Right Value field, specify the subject line keyword Issues as a value:

Figure 5: Applying If Condition on the "Issues" keyword

Similarly, click the Add OR condition button to configure another If Condition for the Errors keyword:

  1. In the Left Value field, pass the Subject data pill from the output of the Get email trigger under the Data Tree Output.

  2. Select the condition as Contains in the Condition field.

  3. In the Right Value field, specify the subject line keyword Errors as a value:

Figure 6: Applying If Condition on the "Errors" keyword

Once all the above OR operators are configured, the If condition statement will look like this:

Figure 7: The If Condition using OR operator statement

Configuring the Asana-Create task action under the If Condition

  1. Click on the Please choose an app bar indented under If Condtion.

  2. Choose the Asana app from the drop-down menu in the App field.

  3. Select the trigger event, Create task, from the drop-down menu in the Action field.

  4. For authorizing Asana, select an existing connection from the drop-down or create a new connection. To create a new one, enter the connection name of your choice and click the Link an account button. If you haven't logged in to your Asana account, you'll be asked to do so.

  5. The input fields will open up upon successful connection establishment.

  6. In the Task name field, enter Customer queries on email.

  7. Select a workspace of your Asana account.

  8. Enter the ID of the project in the Project ID field in which you want to create a task. You'll get this ID in the web URL of your Asana project. If your URL is https://app.asana.com/0/1193883011574545/list then 1193883011574545 is your project ID.

  9. Select the team member in the Assignee field to whom you want to assign the task:

Figure 8: Configuring Asana action

10. Scroll down to the Task notes field, and pass the From, Subject, and Body As Plain Text data pill from the Get email output from the Data Tree Output:

Figure 9: Customizing the task notes

We have now successfully configured creating a task in Asana. Now to acknowledge the customer for the issue raised, let's configure a Gmail action.

Configuring Gmail - Send email action

  1. Click on the Add a step button (+ icon) and select the Simple Action option. Choose the Gmail app from the drop-down and select the action, Send email, from the drop-down menu in the Actions field.

  2. No need to re-authorize the Gmail account as it is already done for the trigger.

  3. In the To field, specify the email address of the customer to whom you want to send an acknowledgment email. It is practically impossible to look for the email address of each customer who has raised the escalation and then manually specify it in this field. Instead, let's use the following data pill and script to do the work for us: var s = ;

    var s1 = s.split('<', 2);

    var s2 = s1[1];

    var s3 = s2.split('>', 2);

    var s4= s3[0];

    s4;

Directly passing the data pill to the To field will result in an error. The data pill contains the email address enclosed within the angle brackets e.g.,<[email protected]>. So sending an email to such an email address with angle brackets will result in the Invalid To header error. To remove these angle brackets, use the above-mentioned script.

6. Switch on the Formula mode of the To field and paste the above script. 7. Specify the subject of the acknowledged email in the Subject field. 8. Enter the message you want to send in the email to the customer in the Message field:

Figure 10: Gmail-Send email action

Now we have completed configuring a journey. The complete flow will look like this:

Figure 11: If Condition using OR operator

Executing the journey

Click the Save Changes button and start the journey execution by clicking the Save & Start button. Now to test this journey, send a test email to the linked Gmail account (the support team's email address in this case) with the subject line including the keyword Escalation. As soon as an email is received, the Get email trigger will listen to it and forward the same to the If Condition block.

The If condition will check whether the subject line contains Escalation OR Issues OR Errors. If yes, a new task will be created in Asana. Click the task to know its details. You can see all the email content of the customer has been added to the task:

Figure 12: Task created in Asana and assigned to a team member

Now, go to the Gmail account from where you have sent this test email. You'll see that an acknowledgment email has been received from the support team:

Figure 13: The acknowledgement email from the support team

To understand the journey execution technically, switch to the History window and check out the input and output of the trigger, If Condition, and actions.

In this way, you can use the AND operator to build the above journey. However, the results might alter since the AND operator checks for each matching condition and then allows the further flow.