If Condition using OR operator
Connect multiple If Conditions using an OR operator to level up the validation criteria of your automated workflow. The workflow executes only when one of the specified conditions is satisfied.
Gupshup Integration Platform 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
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.
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:
- Under the Event section, search for the Gmail app in the Apps list under the New Trigger option.
- Then select the trigger event, Get email, from the Triggers list.
- Authorize Gmail by selecting an existing connection from the drop-down or creating a new connection.
- Select the INBOX label from the drop-down menu in the Label field:
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:
Now let's start configuring the If Condition:
- 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.
- Select the condition as Contains in the Condition field.
- In the Right Value field, specify the subject line keyword Escalation as a value:
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:
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:
Similarly, click the Add OR condition button to configure another If Condition for the Errors keyword:
- In the Left Value field, pass the Subject data pill from the output of the Get email trigger under the Data Tree Output.
- Select the condition as Contains in the Condition field.
- In the Right Value field, specify the subject line keyword Errors as a value:
Once all the above OR operators are configured, the If condition statement will look like this:
Configuring the Asana action under the If Condition
- Click on the Please choose an app bar indented under If Condition.
- Choose the Asana app from the drop-down menu in the App field.
- Select the trigger event, Create task, from the drop-down menu in the Action field.
- 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.
- The input fields will open up upon successful connection establishment.
- In the Task name field, enter Customer queries on email.
- Select a workspace of your Asana account.
- 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.
- Select the team member in the Assignee field to whom you want to assign the task:
- 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:
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
- 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.
- No need to re-authorize the Gmail account as it is already done for the trigger.
- 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]](mailto:[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.
- Switch on the Formula mode of the To field and paste the above script.
- Specify the subject of the acknowledged email in the Subject field.
- Enter the message you want to send in the email to the customer in the Message field:
Now we have completed configuring a journey. The complete flow will look like this:
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 learn its details. You can see all the email content of the customer has been added to the task:
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:
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 further flow.
Updated over 1 year ago