Start using IBM® App Connect on IBM Cloud without charge: create an event-driven flow from a template, to send an email via Gmail when a new lead is created in Salesforce; all in a few steps, in minutes.

Duration: When preparing this article, it took less than 3 minutes from start to finish – to create, start, and test the event-driven flow.

(If you havenâ€™t already connected App Connect to your Gmail account) The name and password of your Gmail account.

(If you havenâ€™t already connected App Connect to your Salesforce account) The name and password of your Salesforce account.

If you want to create a free test account in Salesforce rather than use your business account, make sure that you register for a Developer account from this URL: https://developer.salesforce.com rather than a Trial account. If you connect to App Connect with a Trial account, the Salesforce events donâ€™t work.

In the following steps, we started without App Connect already being connected to the Gmail and Salesforce accounts. We also chose to connect to Gmail and Salesforce as we edited the event-driven flow. (If App Connect was already connected to Gmail and Salesforce accounts, such as from an earlier flow or API, we would not have needed to connect again.)

Create an event-driven flow from a template

Duration: A few minutes

A quick and easy way to create an event-driven flow (or an API flow) is to use a pre-built template from the App Connect gallery of templates. If needed, you can then adapt the template to your needs.

Alternatively, if you don’t see a suitable template, you can import a flow definition file or create a new flow from scratch, perhaps following one of the App Connect tutorials for specific use cases.

Create the flow from the template…

This example uses the template “Send Gmail message to new Salesforce lead”. This template creates and sends an email via Gmail when a new lead is created in Salesforce. If there is no email provided for the lead then App Connect logs an error about the missing email.

To create the event-driven flow from the template, complete the following steps:

This displays the App Connect dashboard, which you’ll later use to manage your event-driven flow.

This also shows other menu bar options, including Catalog to manage your use of the App Connect catalog of applications and APIs, and Templates to browse and select from the App Connect templates for event-driven flows and flows for APIs.

(Click image to view full size)

Click the Templates menu bar option.

In the search box, type send gmail, and then click the tile labelled “Send Gmail message to new Salesforce lead”.

This displays a summary of the template, with brief instructions for how to use the template.

(Click image to view full size)

Click Create flow.

This creates an event-driven flow from the template, and opens the flow in the flow editor.

(Click image to view full size)

Result: The flow is open in the flow editor, ready for us to validate and connect to the applications it uses.

Step 3: Explore and complete the event-driven flow

Duration: A few minutes

When you create a flow from a template, it is good practice to examine the flow to understand its actions. Also, you may need to connect applications used by the flow, or may choose to change an account used or otherwise adapt the flow to your needs.

Note that with a quick glance you can see any nodes that need attention, as they are marked with an exclamation mark in a red circle. If the node shows “Not connected“, this indicates that we need to connect to the application used, which we’ll do in the following steps.

Explore and complete the flow…

Give the flow a name that is unique and meaningful to you.

A flow created from a template is assigned the name of the template title; in this example, “Send Gmail message to new Salesforce lead”. If you want to change the flow name, click the name field and overtype with the name you want to use; for example: Welcome new Salesforce lead with Gmail message.

Examine the event, Salesforce / New lead (Not connected), that will be used to trigger the flow.

Click the event node. This displays the Connect button, for us to connect to the Salesforce account.

Click Connect

This displays the initial page of the Connect to Salesforce dialog.

If required, you can use the Custom URL field to specify a special Salesforce environment (production or sandbox), or subdomain (with a personalized login page) that you want to connect to.

In this example, we left the Custom URL field blank, to connect to the standard (production) environment for our Salesforce Developer account. When connected, App Connect is automatically directed to use the generic production URL: https://login.salesforce.com.

Click Connect

To confirm that you have an appropriate Salesforce account, click Continue.

This opens a Salesforce window for you to connect App Connect. Choose a username, and follow the Salesforce instructions to allow App Connect to access your Salesforce account.

(Click image to view full size)

When completed, the flow editor is updated with the event node now showing the account name used in App Connect for the Salesforce connection (for example, “Account 1”). If you want to change the account name shown, you must do so (on the Catalog / Applications page) before the connection is used by any running flow.

(Click image to view full size)

Examine the If node.

In the flow editor, the view of the If node shows key information. You can see the If and else conditions, and the actions that will be taken.

If the Email property of the new Salesforce lead is not empty, then an email is sent by Gmail.

Else, the flow ends with the message “Email address was not provided for Lead ID = <Lead ID>”, where <Lead ID> is the value of the ID field from the new Salesforce lead.

(Optional) To examine its logic more, click the If node . For each condition, this shows a field from the source application (Salesforce), an operation, and if appropriate, a value for the operation.

When completed, the flow editor is updated with the action node now showing the account name used in App Connect for the Gmail connection (for example, “Account 1”). If you want to change the account name shown, you must do so before the connection is used by any running flow.

(Click image to view full size)

Complete the Gmail fields needed to send the message:

*To: To send an email to the address defined in the new Salesforce lead, map the Email field from that lead:

Click in the *To field.

Start typing email and then pause briefly for App Connect to offer you choices based on “email”.

(Click image to view full size)

Note, when you click in a target field (of Gmail / Create email), icons are shown next to the field: to enable you to map fields from Salesforce / New lead (any node earlier in the flow) or to insert JSONata functions into the target field.

Select Email.

Subject: Add an appropriate subject for the new lead to see. For example:

Type Welcome name, and then pause briefly for App Connect to offer you choices based on “name”.

Select a Salesforce / Lead name field, such as Full name.

(Optional) You can type more text and select more fields to map from Salesforce into the Subject.

Body: Complete an appropriate body to send in the email.

Type text and select fields to map from Salesforce. Alternatively, you can copy and paste the following body example of text, Salesforce fields, and some functions that act on some fields. This example shows the JSONata syntax used to represent fields and functions, which you can adapt as JSONata.

Hello {{$Trigger.Name}}
Welcome to Wonders of App Connect. This will help {{$Trigger.Company}} to quickly connect apps to automate tasks and boost productivity

When pasted into App Connect, the JSONata is given a graphical representation.

(Click image to view full size)

Result: You have examined the flow created from the template, connected App Connect to the applications used, and made some changes to complete and adapt the flow. Now let’s start the flow and examine it further.

Step 4: Test the event-driven flow

Duration: A few minutes

Although we can start the flow from the flow editor, letâ€™s return to the App Connect dashboard where we can explore more options for running and managing the flow.

Click the Dashboard link in the top left of the flow editor. This displays the App Connect dashboard, with a tile for the flow that we have just completed:

(Click image to view full size)

Test the flow…

Explore the flow tile

The flow tile on the App Connect dashboard is the quickest way to find information about a running integration.
When the flow runs, the tile shows an icon with status information such as whether or not the flow ran successfully, any error messages, and the number of records processed; for example:

If the flow tile has a green tick, the flow has run successfully; click the tick to see when the flow was last triggered.

(Click image to view full size)

If the tile has a red exclamation point, thereâ€™s a problem; click the exclamation point to find out whatâ€™s gone wrong.

(Click image to view full size)

You can use the flow tile’s options menu (&vellip;) to select actions to start, stop, and otherwise manage the flow.

Start the flow

Open the options menu (&vellip;) and then click Start flow. The flow tile changes to show a green tick, and the flow is waiting for a new Salesforce lead to be created.

Log in to the Gmail account that you want to use for the new Salesforce lead (that is to receive the email sent by App Connect).

Create a new Salesforce lead:

Log in to Salesforce using the account that you configured in App Connect.

Create a new lead, specifying values for First Name, Last Name, Email (the Gmail account from the previous step), and Company; for example:

(Click image to view full size)

Click Save.

After a brief moment, check the inbox of the Gmail account. You can see an email sent by App Connect (using the Gmail account that you specified on the Gmail / Create email node), containing the data that you specified in the flow; for example:

(Click image to view full size)

Return to the App Connect dashboard, and examine the flow’s tile. Hover the mouse cursor over the green tick to see the message about when the flow last ran successfully; for example:

(Click image to view full size)

Next test the Else condition of the flow, which responds to the creation of Salesforce leads without an email address:

Create a new Salesforce lead, but do not specify an Email address; for example:

(Click image to view full size)

After a brief moment, check the inbox of the Gmail account. You do not see an email sent by App Connect for the new Salesforce lead, because the email address was not specified.

Return to the App Connect dashboard, and examine the flow’s tile. Hover the mouse cursor over the green tick to see the message that the flow ran successfully. (The flow completed successfully, but output a log message for the Else condition.)

Check the App Connect log for the message added for the Else condition.

From the App Connect hamburger menu, expand Manage then click Logs.

(Click image to view full size)

This opens the IBM Cloud Logging window for your App Connect.

Examine the log, noting the message added for the Else condition; for example:

(Click image to view full size)

To see more detail, expand the message; for example:

(Click image to view full size)

Result: You have successfully configured, deployed, and tested your first event-driven flow in App Connect on IBM Cloud.

Get started with App Connect Enterprise software

Start using IBM App Connect Enterprise for Developers without charge: download and then install the software, and then create and deploy your first integration solution, all in a few steps, in minutes: