If Condition

Harness your workflows with the business logic of If Condition to ensure that automations execute only when a specific condition is met. This avoids a user getting results for every trigger event.

If Condition acts as a gateway where a journey executes successfully only when a specified condition is met. The output received from the trigger and previous action(s) is checked thoroughly by If Condition and then it's passed to the actions downstream. In case the condition is not satisfied, If Condition doesn't execute the actions configured in the If block.

You can use If Condition between a trigger and action or action and action, depending on your use case.

Let's consider a business use case to understand If Condition in a more realistic way.


Use case

Fetch a new email in Gmail and send it to another email via Gmail if the subject of the received email contains the word, Demo. In this use case, we will use the Contains condition.

  • Trigger: Gmail-Get email
  • Condition: If Condition as a business logic with Contains as a condition
  • Action: Gmail - Send email

Prerequisites

Before configuring a journey, create a Google Workspace account to have an official Gmail account ready to implement the use case.

Gupshup Integration Platform supports two types of Gmail connectors:

  1. Gmail: This connector is used to connect the official Google Workspace account with Gupshup Integration Platform and perform the tasks accordingly. It requires authorization to establish the connection.
  2. Gmail Secondary: This connector is used to connect a personal Gmail account with Gupshup Integration Platform and perform the tasks accordingly. It requires authentication (client ID and client secret) to establish the connection.

Configuring a trigger

To configure a Gmail trigger, follow these steps:

  1. Under the Event section, search for the Gmail app and click on it.
  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 label INBOX from the drop-down menu in the Label field:
1089

Figure 1: The Gmail trigger


Configuring the If Condition

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

Figure 2: The If Condition

  1. The Setup If condition block will appear with a pre-indented action bar as illustrated here:
1084

Figure 3: The If Condition structure

You will get the following fields to which input is to be specified:

  1. Specify a value in the Left Value field by placing the Subject data pill from the Gmail | Get email Trigger-Data Tree Output on the right-hand side of the screen.

📘

The Left Value field acts as an input to the If Condition. The input of this field is the output of the trigger or previous actions used.

  1. Select the Contains condition from the drop-down in the Condition field.
  2. Specify the Demo keyword as the value in the Right Value field.

📘

An input provided in the Right Value field is a keyword satisfying the condition. It can be a string, integer, date, or timestamp.

1654

Figure 4: Configuring the If condition

👍

You can add OR and AND conditions between 2 or more If Conditions by clicking the Add condition button. It creates a nested If Condition that can handle severe complexities within a journey.

Configure the Gmail action

The following fields will open up in which you need to enter the details:

  1. To (required): Enter the email ID of the recipient to whom you want to send an email. E.g., [email protected].
  2. Subject (required): Enter the subject of the email you want to send
  3. Message (required): Enter the email in rich format text you want to send. The entire email message field is RFC 2822 formatted and supports the base64url writable encoded string. You can also drag and drop the Body as HTML data pill from the output of the Get email trigger under the Data Tree Output.
1632

Figure 5: Configuring a Gmail action

There are some optional fields such as Cc, Bcc, Attachments, etc. to which you can specify the URL of the file and its name that you want to send with the email.
The Gmail to Gmail journey looks like the following screenshot after completing the configuration:

1630

Figure 6: The If Condition journey


Types of conditions

Let's take a tour of If Conditions that Gupshup Integration Platform offers:

Points to remember:

  • All the conditions are case sensitive and support all the data types as an input and output value
  • alt text is the example trigger data pill used to explain the conditions
  1. Equals

The Left Value field (input) equals a value specified in the Right Value field (output).

Example:

Left Value: alt text Let's say the value of this is 5

Condition: Equals

Right Value: 5

Note: In the case of the string data type, the comparison is made based on the ASCII value.

When you run the journey, the Condition field will check whether the value of alt text (which is 5) is equal to value 5 or not. If yes, the defined condition is met, and the journey will proceed to the next action.

  1. Contains

The Left Value (input) field should contain a keyword in the text specified in the Right Value field (output).

Example:

Left Value: alt text Let's say the value of this is Demo Journey.

Condition: Contains

Right Value: Demo

When you run the journey, the Condition field will check whether the value of alt text (which is Demo Journey) contains the keyword Demo or not. If it contains the keyword specified, the defined condition is met and the journey will proceed to the next action.

  1. Does not contain

The Left Value (input) field should not contain a keyword in the text specified in the Right Value field (output).

Example:

Left Value: alt text Let's say the value of this is Demo Journey.

Condition: Does not contain

Right Value: Sample

When you run the journey, the Condition field will check whether the value of alt text (which is Demo Journey) contains the keyword Sample or not. If it does not contain the keyword specified, the defined condition is met and the journey will proceed to the next action.

  1. Does not equal

The Left Value (input) field input should not be equal to the value specified in the Right Value field (output).

Example:

Left Value: alt text Let's say the value of this is 22

Condition: Does not equal

Right Value: 15

When you run the journey, the Condition field will check whether the value of alt text (which is 22) is equal to 15 or not. If it is not identical to the keyword specified, the defined condition is met and the journey will proceed to the next action.

  1. Starts with

The Left Value (input) field input should start with a keyword specified in the Right Value field (output).

Example:

Left Value: alt text Let's say the value of this is Demo Journey.

Condition: Starts with

Right Value: Demo

When you run the journey, the Condition field will check whether the value of alt text (which is Demo Journey) starts with the keyword Demo or not. If it begins with the keyword specified, the defined condition is met and the journey will proceed to the next action.

  1. Does not start with

The Left Value field (input) should not start with a keyword specified in the Right Value field (output).

Example:

Left Value: alt text Let's say the value of this is Demo Journey.

Condition: Does not start with

Right Value: Sample

When you run the journey, the Condition field will check whether the value of alt text (which is Demo Journey) starts with the keyword Sample or not. If it does not begin with the keyword specified, the defined condition is met and the journey will proceed to the next action.

  1. Ends with

The Left Value field (input) should end with a keyword specified in the Right Value field (output).

Example:

Left Value: alt text Let's say the value of this is Demo Journey.

Condition: Ends with

Right Value: Journey

When you run the journey, the Condition field will check whether the value of alt text (which is Demo Journey) ends with the keyword Journey or not. If it ends with the keyword specified, the defined condition is met and the journey will proceed to the next action.

  1. Does not end with

The Left Value field (input) should not end with a keyword specified in the Right Value field (output).

Example:

Left Value: Let's say the value of this is Demo Journey.

Condition: Does not end with

Right Value: Sample

When you run the journey, the Condition field will check whether the value of alt text (which is Demo Journey) does not end with the keyword Sample or not. If it does not end with the keyword specified, the defined condition is met and the journey will proceed to the next action.

  1. Greater than

The Left Value field (input) should be greater than a value specified in the Right Value field (output).

Example:

Left Value: alt text Let's say the value of this is 5

Condition: Greater than

Right Value: 2

Note: In the case of the string data type, the comparison is done on the basis of the ASCII value.

When you run the journey, the Condition field will check whether the value of alt text (which is 5) is greater than the value 2 or not. If yes, the defined condition is met and the journey will proceed to the next action.

10. Greater than equal to

The Left Value field (input) should be greater than or equal to a value specified in the Right Value field (output).

Example:

Left Value: alt text Let's say the value of this is 7

Condition: Greater than equal to

Right Value: 6

Note: In the case of the string data type, the comparison is based on the ASCII value.

When you run the journey, the Condition field will check whether the value of alt text (which is 7) is greater than or equal to the value 6 or not. If yes, the defined condition is met and the journey will proceed to the next action.

  1. Less than

The Left Value field (input) should be less than a value specified in the Right Value field (output).

Example:

Left Value: alt text Let's say the value of this is 3

Condition: Less than

Right Value: 5

Note: In the case of the string data type, the comparison is done on the basis of the ASCII value.

When you run the journey, the Condition field will check whether the value of alt text (which is 3) is less than the value 5 or not. If yes, the defined condition is met and the journey will proceed to the next action.

12. Less than equal to

The Left Value field (input) should be less than or equal to a value specified in the Right Value field (output).

Example:

Left Value: alt text Let's say the value of this is 2

Condition: Less than

Right Value: 5

Note: In the case of the string data type, the comparison is done on the basis of the ASCII value.

When you run the journey, the Condition field will check whether the value of alt text (which is 2) is less than the value 5 or not. If yes, the defined condition is met and the journey will proceed to the next action.

  1. Is true

The Left Value field (input) should be true. In this case, you don't need to specify the value in the Right Value field.

Example:

Left Value: alt text Let's say the value of this is true

Condition: Is true

When you run the journey, the Condition field will check whether the value of alt text (which is true) is true or not. If yes, the defined condition is met and the journey will proceed to the next action.

  1. Is not true

The Left Value field (input) should not be true. In this case, you don't need to specify the value in the Right Value field.

Example:

Left Value: alt text Let's say the value of this is false

Condition: Is not true

When you run the journey, the Condition field will check whether the value of alt text (which is false) is false or not. If yes, the defined condition is met and the journey will proceed to the next action.

  1. Is present

The Left Value field (input) should be present. In this case, you don't need to specify the value in the Right Value field.

Example:

Left Value: alt text Let's say the value of this is abc

Condition: Is present

When you run the journey, the Condition field will check whether the value of alt text (which is abc) is present or not. If yes, the defined condition is met and the journey will proceed to the next action.

  1. Is not present

The Left Value field (input) should not be present. In this case, you don't need to specify the value in the Right Value field.

Example:

Left Value: alt text Let's say the value of this is " alt text "

Condition: Is not present

When you run the journey the Condition field will check whether the value of (which is " alt text ") is unavailable or not. If yes, the defined condition is met and the journey will proceed to the next action.