Red Hat Training

A Red Hat training course is available for Red Hat Fuse

Chapter 5. Create integrations

After some planning and preparation, you are ready to create an integration. In the Fuse Online web interface, when you click Create Integration, Fuse Online guides you through the procedure to create an integration.

The following topics provide information and instructions for creating an integration:

5.1. Preparation for creating an integration

Preparation for creating an integration starts with answers to the questions listed in Plan your integrations. After you have a plan for the integration, you need to do the following before you can create the integration:

  1. Determine whether an application that you want to connect to uses the OAuth protocol. For each application that uses OAuth, register Fuse Online as a client that is authorized to access that application. Applications that use the OAuth protocol include:

    • Dropbox
    • Gmail
    • Google Calendar
    • Salesforce
    • SAP Concur
    • Twitter
  2. Determine whether an application that you want to connect to uses HTTP basic authentication. For each application that does, identify the user name and password for accessing that application. You need to provide this information when you create the integration.
  3. For each application that you want to integrate, create a connection.

5.2. Procedure for creating an integration

Fuse Online guides you through the procedure for creating an integration. It prompts you to choose the start connection, the finish connection, optional middle connections, and other steps. When your integration is complete, you can publish it so that it is running or you can save it for publication at a later time.

Prerequisites

  • You have a plan for what the steps in the integration will be.
  • You created a connection to each application or service that you want to connect to in this integration.

Procedure

  1. In the left panel in Fuse Online, click Integrations.
  2. In the upper right, click Create Integration.
  3. Choose and configure the start connection:

    1. On the Choose a Start Connection page, click the connection that you want to use to start the integration. When this integration is running, Fuse Online will connect to this application and obtain data that you want the integration to operate on.
    2. On the Choose an Action page, click the action you want this connection to perform. The available actions vary for each connection.
    3. On the page for configuring the action, enter values in the fields.
    4. Optionally, if the connection requires data type specification, Fuse Online prompts you to click Next to specify the input and/or output type of the action.
    5. Click Done to add the start connection.

    As an alternative to connecting to an application, a start connection can be a timer that triggers integration execution at intervals that you specify or it can be a webhook that accepts HTTP requests.

  4. Choose and configure the finish connection:

    1. On the Choose a Finish Connection page, click the connection you want to use to complete the integration. When this integration is running, Fuse Online will connect to this application with the data that the integration has been operating on.
    2. On the Choose an Action page, click the action you want this connection to perform. The available actions vary for each connection.
    3. On the page for configuring the action, enter values in the fields.
    4. Optionally, if the connection requires data type specification, Fuse Online prompts you to click Next to specify the input and/or output type of the action.
    5. Click Done to add the finish connection.

    As an alternative to connecting to an application, a finish connection can send information to the integration’s log about the messages that the integration processed.

  5. Optionally, add one or more connections between the start connection and the finish connections. For each connection, choose its action and enter any required configuration details.
  6. Optionally, add one or more steps that operate on integration data between connections. See About adding steps between connections.
  7. When the integration contains all needed steps, click Save as Draft or Publish according to whether you want to start running the integration.
  8. In the Integration Name field, enter a name that distinguishes this integration from any other integrations.
  9. In the Description field, enter a description, for example, you can indicate what this integration does.
  10. If you are ready to start running the integration, in the upper right, click Publish. Otherwise, click Save as Draft.

Results

In the Fuse Online Integrations page, you can see your new integration in the list of integrations. If you published the integration, then you can see that Fuse Online is in the process of publishing it. It may take a few moments for the status of the integration to become Running. If you saved the integration as a draft, then Draft appears on the integration’s entry.

Click the integration’s entry to see a summary of the integration, including its version history, logs for each execution, and aggregate execution metrics.

5.3. About adding steps between connections

After you add connections to an integration, you can optionally add steps between connections. Each step operates on data obtained from the previous connection(s) and any other previous steps and makes the resulting data available to the next step in the integration.

Often, you must map data fields that are received from a connection to data fields that the next connection in the integration can operate on. After you add all connections to your integration, check the integration visualization panel on the left. For each connection that requires data mapping before it can operate on the input data, Fuse Online displays DataTypeMismatchWarning . Click this icon to see Data Type Mismatch: Add a data mapping step before this connection to resolve the difference.

Click the link in the message to display the Configure Mapper page in which you add and specify a data mapping step.

5.4. Add a data mapping step

Almost all integrations require data mapping. A data mapper step maps data fields from the previous connection(s) and any other steps to data fields that the next connection in the integration can operate on. For example, suppose the integration data contains a Name field and the next connection in the integration has a CustomerName field. You need to map the source Name field to the target CustomerName field.

Prerequisite

You are creating a new integration or editing an integration.

Procedure

  1. In the left panel, where you want to add a data mapper step, hover over the PlusSignToAddStepOrConnection .
  2. In the popup that appears, click Add a Step.
  3. On the Choose a Step page, click Data Mapper to display source and target fields.

5.5. Add a basic filter step

You can add a step to an integration to filter the data that the integration operates on. In a filter step, Fuse Online inspects the data and continues the integration only if the content meets criteria that you define. For example, in an integration that obtains data from Twitter, you can specify that you want to continue the integration by operating only on tweets that contain "Red Hat".

Prerequisites

  • The integration contains all connections that it needs to.
  • You are creating or editing an integration.

Procedure

  1. In the left panel, where you want to add a filter step to the integration, hover over the PlusSignToAddStepOrConnection and in the popup that appears, click Add a Step.
  2. On the Add a Step page, click Basic Filter.
  3. On the Configure Basic Filter Step page, in the Continue only if incoming data match field, select one of the following options:

    • Accept the default that all defined rules must be satisfied.
    • Indicate that only one rule must be satisfied by selecting ANY of the following.
  4. Define the filter rule:

    1. For this field: In the field on the left, enter the name of the field that contains the content you want the filter to evaluate. For example, suppose the data coming in to the step consists of tweets that mention your Twitter handle. You want to continue the integration only when the tweet contains certain content. The tweet is in a field named text so you enter or select text as the value in the first field.

      You can define the field value in the following ways:

      • Start typing. The data name field has a typeahead feature that provides a list of possible completions for you in a pop-up box. Select the correct one from the box.
      • Click in the text field. A dropdown box appears with a list of available fields. Select the field of interest from the list.
    2. This condition must be satisfied: In the middle field, select a condition from the dropdown box. The setting defaults to Contains. For the integration to continue, the condition that you select in this field must be true for the value that you enter in the third field.
    3. For this value: In the third field, enter a value to filter on. For example, if you want to operate on mentions of a certain product from the Twitter feed, you would enter the product name here.
  5. Optionally, click + Add another rule and define another rule.

    You can delete a rule by clicking the trash can icon next to the entry.

  6. When the filter step is complete, click Done to add it to the integration.

Additional resource

If you cannot define the filter you need in a basic filter step, see Add an advanced filter step.

5.6. Add an advanced filter step

In a filter step, Fuse Online inspects the data and continues the integration only if the content meets criteria that you define. If the basic filter step does not let you define the exact filter you need, then add an advanced filter step.

Prerequisites

  • The integration contains all connections that it needs to.
  • You are creating or editing an integration.

Procedure

  1. In the left panel, where you want to add an advanced filter step to the integration, hover over the PlusSignToAddStepOrConnection and in the popup that appears, click Add a Step.
  2. Select Advanced Filter.
  3. In the edit box, use the Camel Simple Expression language to specify a filter expression. For example, the following expression evaluates to true when the message header’s type field is set to widget:

    ${in.header.type} == 'widget'

    In the following example, the expression evaluates to true when the body of the message contains a title field:

    ${in.body.title}
  4. Click Done to add the advanced filter step to the integration.

5.7. Add a log step

Fuse Online provides information about each execution of an integration. To learn what information is automatically provided, see View integration activity information.

To obtain additional information, between any two steps, add a log step or a log connection to the integration. See Comparison of log step and log connection.

For each message that an integration receives, a log step can provide one or more of the following:

  • The message’s header, which provides metadata about the message.
  • The message’s body, which provides the content of the message.
  • Text that you specify either explicitly or through evaluation of an Apache Camel Simple language expression.

Prerequisites

  • You are creating an integration or editing an integration.
  • The integration already has its start and finish connections.

Procedure

  1. In the integration visualization panel on the left, hover over the Plus Sign at the location where you want to add a log step.
  2. In the popup, click Add a Step.
  3. On the Choose a Step page, click Log.
  4. On the Configure Log Step page, select the content that you want to log. If you select Custom text, then in the text input field, enter one of the following:

    • The text that you want to log
    • A Camel Simple language expression

    If you enter an expression, Fuse Online resolves the expression and logs the resulting text.

  5. When log step configuration is complete, click Done to add the step to the integration.
  6. When the integration is complete, publish it to start seeing output from the new log step.

Additional resources

  • To finish an integration by logging information about the messages that an integration processes, or to log message information at a particular log level, Add a log connection instead of a log step.
  • After an integration that has a log step has been executed, output from its log step appears in the integration’s Activity tab. See View integration activity information.

5.8. Add a template step

In an integration, a template step takes data from a source and inserts it into the format that is defined in a template that you upload to Fuse Online. The benefit of a template step is that it provides data output in a consistent format that you specify.

In the template, you define placeholders and specify static text. When you create the integration, you add a template step, map source fields to the template placeholders, and then map template content to the next step in the integration. When the integration executes, Fuse Online inserts the values that are in the mapped source fields into an instance of the template and passes the result to the next step in the integration.

If an integration includes a template step then it is most likely the only template step in the integration. However, more than one template step in an integration is allowed.

In this release, Fuse Online supports only Mustache templates. It is expected that Velocity and Freemarker templates will be supported in a future release.

Prerequisites

  • You must be creating or editing an integration.
  • If you are creating an integration then it must already have its start and finish connections.

Procedure

  1. In the integration visualization panel on the left, hover over the Plus Sign at the location where you want to add a template step.
  2. In the popup, click Add a Step.
  3. On the Choose a Step page, click Template. The Upload Template page opens and prompts you to choose how you want to define the template.
  4. To define the template, do one of the following:

    • Drag and drop a template file or a file that contains text that you want to modify to create a template, into the template editor.
    • Click browse to upload, navigate to a file, and upload it.
    • In the template editor, start typing to define a template.

      Note that you might upload a template that is valid in other environments but that has errors in Fuse Online. Fuse Online requires that you append the body. prefix to each placeholder inside double curly braces. For example, while {{text}} is valid in a typical template, you must specify {{body.text}} in a template that you use with Fuse Online. Here is an example of a valid template:

    At {{body.time}}, {{body.name}} tweeted:
    {{body.text}}
  5. In the template editor, ensure that the template is valid for use with Fuse Online. Fuse Online displays a red error indicator to the left of a line that contains a syntax error. Hovering over a red indicator displays hints about how to resolve the error.

    Inside each set of double curly braces, the body. prefix is required. Data mapping does not work if the body. prefix is missing. For example, if you upload a template that does not have the body. prefix on each placeholder, Fuse Online displays an error icon on those lines.

  6. Click Done to add the template step to the integration.

    If the Done button is not enabled then there is at least one syntax error that you must correct.

    Input to a template step must be in the form of a JSON object. Consequently, you must add a data mapping step before a template step.

  7. To add a data mapper step before the template step:

    1. In the left panel, hover over the Plus Sign that is immediately before the template step that you just added and then click Add a Step.
    2. On the Choose a Step page, click Data Mapper.
    3. In the data mapper, map a source field to each template placeholder field.

      For example, using the template above, map a source field to each of these template fields:

      • body.time
      • body.name
      • body.text
    4. In the upper right, click Done to add the data mapper step to the integration.

    Output from a template step is always a JSON object. Consequently, you must add a data mapper step after a template step.

  8. To add a data mapper step after the template step:

    1. In the left panel, hover over the Plus Sign that is immediately after the template step you just added and then click Add a Step.
    2. On the Choose a Step page, click Data Mapper.
    3. In the data mapper, map the template’s message field, which always contains the result of inserting source fields into the template, to a target field. For example, suppose that a Gmail connection is next in the integration and you want to send the result of the template step as the content of a Gmail message. To do this, you would map the message source field to the text target field.
    4. In the upper right, click Done.

Additional resources

5.9. Add a custom step

If Fuse Online does not provide a step that you need in an integration, a developer can define one or more custom steps in an extension. A custom step operates on integration data between connections.

You add a custom step to an integration in the same way that you add a built-in step. Create an integration, choose the start and finish connections, add other connections as needed and then add additional steps. When you add a step, Fuse Online operates on the data it receives from the previous step(s).

Prerequisites

  • You uploaded the custom step extension to Fuse Online. See Make extensions available.
  • You are creating or editing an integration.
  • The integration already has all the connections that it requires.

Procedure

  1. In the left panel, where you want to add a custom step to the integration, hover over the PlusSignToAddStepOrConnection and in the popup that appears, click Add a Step.
  2. On the Add a Step page, click the custom step that you want to add.

    The list of available steps includes any custom steps that are defined in extensions that were uploaded to your Fuse Online environment.

At the top of the list of steps, in the Name field, you can select Custom Steps to display only custom steps.

  1. Respond to prompts for any information that is required to perform the step. This information varies for each custom step.