Stay organized with collections Save and categorize content based on your preferences.

See the supported connectors for Application Integration.

Try the sample integration

While provisioning Application Integration in your Google Cloud project for the first time, Application Integration, by default, creates an unpublished sample integration named ExampleIntegration-EcomOrderProcessing.

To view the sample integtration, do the following:

  1. In the Google Cloud console, go to the Application Integration page.

    Go to Application Integration

  2. In the navigation menu, click Integrations.

    The Integrations List page appears.

  3. Click the integration named ExampleIntegration-EcomOrderProcessing.

    This opens the sample integration in the integration designer.

  4. Sample integration layout image

You can use this sample integration to get a hands-on experience of the various triggers, tasks, and concepts of Application Integration.

The sample integration illustrates a basic e-commerce back-end scenario implementing the following order processing operation:

  1. Receive the following order request payload from an API endpoint:
    {
      "order_no": "12345",
      "buyer_id": "raambo",
      "line_items": [
        {
          "line": 1,
          "sku": "tr100",
          "vendor": "Internal",
          "quantity": 1,
          "price_per_unit": 10
        },
        {
          "line": 2,
          "sku": "tbz",
          "vendor": "External",
          "quantity": 24,
          "price_per_unit": 1
        }
      ]
    }
    
  2. Extract the order payload and calculate the total order value.
  3. Check if the total order value is greater than or equal to $100. If yes, then get an additional approval to continue.
  4. Check if any of the order items have an external vendor. If yes, then send the details to the vendor using a REST API call.
  5. Send out the order response with the total order value, filtered external vendor items and their respective HTTP response status.

The following table lists all the triggers, tasks, and edge conditions used in ExampleIntegration-EcomOrderProcessing:

Component Configuration Description
API trigger

(OrderProcessAPITrigger)

Trigger ID: api_trigger/ecom-order-processing_API_1 Invokes the integration for every order request.
Data mapping task

(Find Total Order Price)

Input Output Extracts the order_request JSON input variable and iterates through all the order items using the FOR_EACH mapping function to calculate the total order price value.

The total order price value is calculated by multiplying the item quantity and the price_per_item using the GET_PROPERTY and MULTIPLY mapping functions.

The final value is then converted to a double data type and stored in the total_order_value output variable.

orders_request.line_items
.FOR_EACH(~obj1->~obj1
  .GET_PROPERTY("quantity")
  .TO_DOUBLE()
  .MULTIPLY(~obj1
    .GET_PROPERTY("price_per_unit")
    .TO_DOUBLE()))
.TO_DOUBLE_ARRAY()
.SUM()
total_order_value
Edge condition

(Total OrderValue Above Threshold)

Condition: $total_order_value$ >= $threshold_order_value$ Checks if the total order value is greater than or equal to $100. If yes, then the control is passed to an Approval task.
Edge condition

(TotalOrderValue Below Threshold)

Condition: $total_order_value$ < $threshold_order_value$ Checks if the total order value is less than $100. If yes, then the control is passed to the Filter External Items task.
Approval task

(Approval)

Recipients: Enter the approver's email address

For the purpose of testing this sample integration, you can use your email to confirm the successful completion of the integration.

Send an approval request email to one or more integration users. The email includes a link to the integration where the users can manually approve or reject the request.
Data mapping task

(Filter External Items)

Input Output Extracts the order_request JSON input variable and filters all the order items with external vendors using the FILTER mapping function.

The filtered values are then stored in the filtered_external_items output variable.

orders_request
.GET_PROPERTY("line_items")
.FILTER(~obj1->~obj1
  .GET_PROPERTY("vendor")
  .TO_STRING()
  .EQUALS("External"))
filtered_external_items
For Each Loop task

(For Each Loop)

List to iterate: filtered_external_items

API Trigger ID: api_trigger/ecom-order-processing_API_2

Integration name: ExampleIntegration-EcomOrderProcessing

Iterates over the filtered_external_items variable and calls the sub-integration for each element in the array. It also collates the response of each run in rest_call_response_status, where each element of the array has the response from one particular run.
API trigger

(Report ExternalOrders)

Trigger ID: api_trigger/ecom-order-processing_API_2 Invokes the sub-integration for each element in filtered_external_items.
Call REST Endpoint task

(Call REST Endpoint)

Endpoint base URL: https://mocktarget.apigee.net/echo

HTTP method: POST

Request body: sub_integration_input

Makes a REST call to https://mocktarget.apigee.net/echo.

Publish and test the sample integration

Test using the Application Integration integration designer

Do the following to publish and test the sample integration:

  1. Click Test in the integration designer toolbar, and then select OrderProcessAPITrigger.
  2. In the Confirm Publish and Test dialog, click Publish & Test.

    You are prompted to enter a test value for the orders_request input variable. For the purpose of this test, you can directly click TEST INTEGRATION.

For more information about testing, see Testing integrations.

The sample integration sends an approval request email to the email address specified in the Recipients field of the Approval task. The integration order operation will successfully complete once the approval is received.

Do the following to inspect the execution logs and to view the status and payload of the given integration:

  1. Click LOGS in the toolbar of the integration designer.
  2. On the Execution Logs page, you can view details about each attempt to run an integration. Each entry includes details for the execution attempt, including:
    • Integration name
    • Execution ID
    • Status
    • Start time
    • Duration
    • Integration Version
    • Trigger ID
  3. Click the expander arrow (>) next to the executed integration to view an expanded list of tasks and variables in the integration, along with task status and variable payloads.

Test using a REST API call

Now that the integration is published and running, you can invoke it using the following POST REST call:

URL:
https://REGIONAL_SERVICE_ENDPOINT/v1/projects/project-name/locations/-/integrations/ExampleIntegration-EcomOrderProcessing:execute 
Request body:
{"trigger_id":"api_trigger/ecom-order-processin_API_1"}

For information about the available Application Integration service endpoints, see Application Integration Service endpoints.

Example 1: Send request with default inputs

curl -v -X POST -H "Content-Type: application/json" -d
'{"trigger_id":"api_trigger/ecom-order-processing_API_1"}'
'https://REGIONAL_SERVICE_ENDPOINT/v1/projects/project-name/locations/-/integrations/ExampleIntegration-EcomOrderProcessing:execute' -H "Authorization: Bearer $(gcloud auth AUTH_PROFILE)"

Example 2: Send request with custom inputs

curl -v -X POST -H "Content-Type: application/json"
'https://REGIONAL_SERVICE_ENDPOINT/v1/projects/project-name/locations/-/integrations/ecom-order-processing:execute' -H "Authorization: Bearer $(gcloud auth AUTH_PROFILE)" -d
'{ "triggerId": "api_trigger/ecom-order-processing_API_1",
  "inputParameters": {
      "orders_request": {
          "jsonValue": "{\n  \"order_no\": \"12345\",\n  \"buyer_id\": \"raambo\",\n  \"line_items\": [{\n    \"line\": 1.0,\n    \"sku\": \"tr100\",\n    \"vendor\": \"Internal\",\n    \"quantity\": 1.0,\n    \"price_per_unit\": 10.0\n  }, {\n    \"line\": 2.0,\n    \"sku\": \"tbz\",\n    \"vendor\": \"External\",\n    \"quantity\": 24.0,\n    \"price_per_unit\": 2.0\n  }]\n}"
      }
  }
}'

The API returns the integration execution response containing all the integration output variable values.

Upload and try the sample integration

The entire sample integration is available in a JSON file, which you can directly upload in another integration project. Uploading an integration creates a new version of the integration in the project where the file is uploaded.

You can download the sample integration JSON file here.

To upload the sample integration, do the following:

  1. In the Google Cloud console, go to the Application Integration page.

    Go to Application Integration

  2. In the navigation menu, click Integrations.

    The Integrations List page appears.

  3. Create a new integration by clicking CREATE INTEGRATION.
  4. Enter the integration name as ExampleIntegration-EcomOrderProcessing and (optionally) provide a description in the Create Integration dialog.
  5. This opens the integration designer page.

  6. In the integration designer, click Upload/download menu and then select Upload integration.
  7. In the file browser dialog, select the ExampleIntegration-EcomOrderProcessing.json file, and then click Open.

    A new version of the integration is created using the uploaded file.