Application Integration에 지원되는 커넥터를 참조하세요.

전자상거래 샘플 통합

이 샘플 통합은 전자상거래 백엔드 시나리오 사용 사례를 보여줍니다.

더 살펴보기

이 코드 샘플이 포함된 자세한 문서는 다음을 참조하세요.

코드 샘플

{
  "description": "The integration mimics the back office e-commerce order processing. The request is expected to contain order with one or more line items as json object with sku, quantity, price, vendor etc. If the total price of the order goes beyond $100 then there will be an email sent to approve the order else the order will be processed successfully. For all the items which have vendor as external, there will be an external order created by making a rest call to the external server. The response of the integration will be total order value, filtered list of external items and list of http response status received for each rest call made per external line_item.",
  "triggerConfigs": [{
    "label": "OrderProcessApiTrigger",
    "startTasks": [{
      "taskId": "1"
    }],
    "properties": {
      "Trigger name": "ecom-order-processing_API_1"
    },
    "triggerType": "API",
    "triggerNumber": "1",
    "triggerId": "api_trigger/ecom-order-processing_API_1",
    "position": {
      "x": -294,
      "y": -252
    }
  }, {
    "label": "ReportExternalOrders",
    "startTasks": [{
      "taskId": "6"
    }],
    "properties": {
      "Trigger name": "ecom-order-processing_API_2"
    },
    "triggerType": "API",
    "triggerNumber": "2",
    "triggerId": "api_trigger/ecom-order-processing_API_2",
    "position": {
      "x": 210,
      "y": -84
    }
  }],
  "taskConfigs": [{
    "task": "SuspensionTask",
    "taskId": "2",
    "parameters": {
      "customMessage": {
        "key": "customMessage",
        "value": {
          "stringValue": "Hello user, approval request from EcomOrderProcessing integration."
        }
      },
      "isApproved": {
        "key": "isApproved",
        "value": {
          "stringArray": {
            "stringValues": ["$`Task_2_isApproved`$"]
          }
        }
      },
      "suspensionExpiration": {
        "key": "suspensionExpiration",
        "value": {
          "jsonValue": "{\n  \"@type\": \"type.googleapis.com/enterprise.crm.eventbus.proto.SuspensionExpiration\",\n  \"remindAfterMs\": 86400000,\n  \"expireAfterMs\": 172800000\n}"
        }
      },
      "notifications": {
        "key": "notifications",
        "value": {
          "jsonValue": "{\n  \"protoValues\": [{\n    \"@type\": \"type.googleapis.com/enterprise.crm.eventbus.proto.Notification\",\n    \"emailAddress\": {\n      \"email\": \"\\u003cchange-this-to-email-id\\u003e\"\n    }\n  }]\n}"
        }
      }
    },
    "nextTasks": [{
      "taskId": "3",
      "condition": "$`Task_2_isApproved`$ \u003d true",
      "displayName": "Proceed if approved"
    }],
    "taskExecutionStrategy": "WHEN_ALL_SUCCEED",
    "displayName": "Approval",
    "successPolicy": {
      "finalState": "SUSPENDED"
    },
    "externalTaskType": "NORMAL_TASK",
    "position": {
      "x": -42
    }
  }, {
    "task": "FieldMappingTask",
    "taskId": "1",
    "parameters": {
      "FieldMappingConfigTaskParameterKey": {
        "key": "FieldMappingConfigTaskParameterKey",
        "value": {
          "jsonValue": "{\n  \"@type\": \"type.googleapis.com/enterprise.crm.eventbus.proto.FieldMappingConfig\",\n  \"mappedFields\": [{\n    \"inputField\": {\n      \"fieldType\": \"DOUBLE_VALUE\",\n      \"transformExpression\": {\n        \"initialValue\": {\n          \"referenceValue\": \"$orders_request$\"\n        },\n        \"transformationFunctions\": [{\n          \"functionType\": {\n            \"jsonFunction\": {\n              \"functionName\": \"GET_PROPERTY\"\n            }\n          },\n          \"parameters\": [{\n            \"initialValue\": {\n              \"literalValue\": {\n                \"stringValue\": \"line_items\"\n              }\n            }\n          }]\n        }, {\n          \"functionType\": {\n            \"jsonFunction\": {\n              \"functionName\": \"FOR_EACH\"\n            }\n          },\n          \"parameters\": [{\n            \"initialValue\": {\n              \"literalValue\": {\n                \"protoValue\": {\n                  \"@type\": \"type.googleapis.com/enterprise.crm.eventbus.proto.TransformExpression\",\n                  \"initialValue\": {\n                    \"referenceValue\": \"~x\"\n                  },\n                  \"transformationFunctions\": [{\n                    \"functionType\": {\n                      \"jsonFunction\": {\n                        \"functionName\": \"GET_PROPERTY\"\n                      }\n                    },\n                    \"parameters\": [{\n                      \"initialValue\": {\n                        \"literalValue\": {\n                          \"stringValue\": \"quantity\"\n                        }\n                      }\n                    }]\n                  }, {\n                    \"functionType\": {\n                      \"jsonFunction\": {\n                        \"functionName\": \"TO_DOUBLE\"\n                      }\n                    }\n                  }, {\n                    \"functionType\": {\n                      \"doubleFunction\": {\n                        \"functionName\": \"MULTIPLY\"\n                      }\n                    },\n                    \"parameters\": [{\n                      \"initialValue\": {\n                        \"referenceValue\": \"~x\"\n                      },\n                      \"transformationFunctions\": [{\n                        \"functionType\": {\n                          \"jsonFunction\": {\n                            \"functionName\": \"GET_PROPERTY\"\n                          }\n                        },\n                        \"parameters\": [{\n                          \"initialValue\": {\n                            \"literalValue\": {\n                              \"stringValue\": \"price_per_unit\"\n                            }\n                          }\n                        }]\n                      }, {\n                        \"functionType\": {\n                          \"jsonFunction\": {\n                            \"functionName\": \"TO_DOUBLE\"\n                          }\n                        }\n                      }]\n                    }]\n                  }]\n                }\n              }\n            }\n          }]\n        }, {\n          \"functionType\": {\n            \"jsonFunction\": {\n              \"functionName\": \"TO_DOUBLE_ARRAY\"\n            }\n          }\n        }, {\n          \"functionType\": {\n            \"doubleArrayFunction\": {\n              \"functionName\": \"SUM\"\n            }\n          }\n        }]\n      }\n    },\n    \"outputField\": {\n      \"referenceKey\": \"$total_order_value$\",\n      \"fieldType\": \"DOUBLE_VALUE\",\n      \"cardinality\": \"OPTIONAL\"\n    }\n  }]\n}"
        }
      }
    },
    "nextTasks": [{
      "taskId": "2",
      "condition": "$total_order_value$ \u003e\u003d $threshold_order_value$",
      "displayName": "TotalOrderValue Above Threshold ",
      "description": "Checks if the total order value is greater than or equal to $100"
    }, {
      "taskId": "3",
      "condition": "$total_order_value$ \u003c $threshold_order_value$",
      "displayName": "TotalOrderValue Below Threshold",
      "description": "Checks if the total order value is less than $100"
    }],
    "taskExecutionStrategy": "WHEN_ALL_SUCCEED",
    "displayName": "Find Total Order Price",
    "externalTaskType": "NORMAL_TASK",
    "position": {
      "x": -294,
      "y": -126
    }
  }, {
    "task": "FieldMappingTask",
    "taskId": "5",
    "parameters": {
      "FieldMappingConfigTaskParameterKey": {
        "key": "FieldMappingConfigTaskParameterKey",
        "value": {
          "jsonValue": "{\n  \"@type\": \"type.googleapis.com/enterprise.crm.eventbus.proto.FieldMappingConfig\",\n  \"mappedFields\": [{\n    \"inputField\": {\n      \"fieldType\": \"JSON_VALUE\",\n      \"transformExpression\": {\n        \"initialValue\": {\n          \"literalValue\": {\n            \"stringValue\": \"{\\\"STATUS\\\" : \\\"PROCESSING_COMPLETE\\\"}\"\n          }\n        },\n        \"transformationFunctions\": [{\n          \"functionType\": {\n            \"stringFunction\": {\n              \"functionName\": \"TO_JSON\"\n            }\n          }\n        }]\n      }\n    },\n    \"outputField\": {\n      \"referenceKey\": \"$orders_response$\",\n      \"fieldType\": \"JSON_VALUE\",\n      \"cardinality\": \"OPTIONAL\"\n    }\n  }]\n}"
        }
      }
    },
    "taskExecutionStrategy": "WHEN_ALL_SUCCEED",
    "displayName": "Build Response",
    "externalTaskType": "NORMAL_TASK",
    "position": {
      "x": -294,
      "y": 378
    }
  }, {
    "task": "SubWorkflowForEachLoopV2Task",
    "taskId": "4",
    "parameters": {
      "iterationElementMapping": {
        "key": "iterationElementMapping",
        "value": {
          "stringValue": "sub_integration_input"
        }
      },
      "aggregatorParameterMapping": {
        "key": "aggregatorParameterMapping",
        "value": {
          "jsonValue": "{\n  \"@type\": \"type.googleapis.com/enterprise.crm.eventbus.proto.ParameterMap\",\n  \"entries\": [{\n    \"key\": {\n      \"literalValue\": {\n        \"stringValue\": \"`Task_6_responseStatus`\"\n      }\n    },\n    \"value\": {\n      \"literalValue\": {\n        \"stringValue\": \"rest_call_response_status\"\n      }\n    }\n  }]\n}"
        }
      },
      "triggerId": {
        "key": "triggerId",
        "value": {
          "stringValue": "api_trigger/ecom-order-processing_API_2"
        }
      },
      "loopMetadata": {
        "key": "loopMetadata",
        "value": {
          "stringArray": {
            "stringValues": ["$`Task_4_loopMetadata`$"]
          }
        }
      },
      "disableEucPropagation": {
        "key": "disableEucPropagation",
        "value": {
          "booleanValue": false
        }
      },
      "listToIterate": {
        "key": "listToIterate",
        "value": {
          "stringValue": "$filtered_external_items$"
        }
      },
      "workflowName": {
        "key": "workflowName",
        "value": {
          "stringValue": "ExampleIntegration-EcomOrderProcessing"
        }
      },
      "requestParameterMapping": {
        "key": "requestParameterMapping"
      },
      "overrideParameterMapping": {
        "key": "overrideParameterMapping"
      }
    },
    "nextTasks": [{
      "taskId": "5"
    }],
    "taskExecutionStrategy": "WHEN_ALL_SUCCEED",
    "displayName": "For Each Loop",
    "externalTaskType": "NORMAL_TASK",
    "position": {
      "x": -294,
      "y": 252
    }
  }, {
    "task": "FieldMappingTask",
    "taskId": "3",
    "parameters": {
      "FieldMappingConfigTaskParameterKey": {
        "key": "FieldMappingConfigTaskParameterKey",
        "value": {
          "jsonValue": "{\n  \"@type\": \"type.googleapis.com/enterprise.crm.eventbus.proto.FieldMappingConfig\",\n  \"mappedFields\": [{\n    \"inputField\": {\n      \"fieldType\": \"JSON_VALUE\",\n      \"transformExpression\": {\n        \"initialValue\": {\n          \"referenceValue\": \"$orders_request$\"\n        },\n        \"transformationFunctions\": [{\n          \"functionType\": {\n            \"jsonFunction\": {\n              \"functionName\": \"GET_PROPERTY\"\n            }\n          },\n          \"parameters\": [{\n            \"initialValue\": {\n              \"literalValue\": {\n                \"stringValue\": \"line_items\"\n              }\n            }\n          }]\n        }, {\n          \"functionType\": {\n            \"jsonFunction\": {\n              \"functionName\": \"FILTER_ELEMENTS\"\n            }\n          },\n          \"parameters\": [{\n            \"initialValue\": {\n              \"literalValue\": {\n                \"protoValue\": {\n                  \"@type\": \"type.googleapis.com/enterprise.crm.eventbus.proto.TransformExpression\",\n                  \"initialValue\": {\n                    \"referenceValue\": \"~x\"\n                  },\n                  \"transformationFunctions\": [{\n                    \"functionType\": {\n                      \"jsonFunction\": {\n                        \"functionName\": \"GET_PROPERTY\"\n                      }\n                    },\n                    \"parameters\": [{\n                      \"initialValue\": {\n                        \"literalValue\": {\n                          \"stringValue\": \"vendor\"\n                        }\n                      }\n                    }]\n                  }, {\n                    \"functionType\": {\n                      \"jsonFunction\": {\n                        \"functionName\": \"TO_STRING\"\n                      }\n                    }\n                  }, {\n                    \"functionType\": {\n                      \"stringFunction\": {\n                        \"functionName\": \"EQUALS\"\n                      }\n                    },\n                    \"parameters\": [{\n                      \"initialValue\": {\n                        \"literalValue\": {\n                          \"stringValue\": \"External\"\n                        }\n                      }\n                    }]\n                  }]\n                }\n              }\n            }\n          }]\n        }]\n      }\n    },\n    \"outputField\": {\n      \"referenceKey\": \"$filtered_external_items$\",\n      \"fieldType\": \"JSON_VALUE\",\n      \"cardinality\": \"OPTIONAL\"\n    }\n  }]\n}"
        }
      }
    },
    "nextTasks": [{
      "taskId": "4"
    }],
    "taskExecutionStrategy": "WHEN_ANY_SUCCEED",
    "displayName": "Filter External Items",
    "description": "Filtering out line_items which have vendor as \"External\" so that we can place order request to the vendor",
    "externalTaskType": "NORMAL_TASK",
    "position": {
      "x": -294,
      "y": 126
    }
  }, {
    "task": "GenericRestV2Task",
    "taskId": "6",
    "parameters": {
      "throwError": {
        "key": "throwError",
        "value": {
          "booleanValue": false
        }
      },
      "responseBody": {
        "key": "responseBody",
        "value": {
          "stringArray": {
            "stringValues": ["$`Task_6_responseBody`$"]
          }
        }
      },
      "disableSSLValidation": {
        "key": "disableSSLValidation",
        "value": {
          "booleanValue": false
        }
      },
      "httpParams": {
        "key": "httpParams"
      },
      "responseHeader": {
        "key": "responseHeader",
        "value": {
          "stringArray": {
            "stringValues": ["$`Task_6_responseHeader`$"]
          }
        }
      },
      "userAgent": {
        "key": "userAgent",
        "value": {
          "stringValue": ""
        }
      },
      "httpMethod": {
        "key": "httpMethod",
        "value": {
          "stringValue": "POST"
        }
      },
      "responseStatus": {
        "key": "responseStatus",
        "value": {
          "stringArray": {
            "stringValues": ["$`Task_6_responseStatus`$"]
          }
        }
      },
      "url": {
        "key": "url",
        "value": {
          "stringValue": "https://mocktarget.apigee.net/echo"
        }
      },
      "urlFetchingService": {
        "key": "urlFetchingService",
        "value": {
          "stringValue": "HARPOON"
        }
      },
      "useSSL": {
        "key": "useSSL",
        "value": {
          "booleanValue": false
        }
      },
      "requestorId": {
        "key": "requestorId",
        "value": {
          "stringValue": ""
        }
      },
      "urlQueryStrings": {
        "key": "urlQueryStrings"
      },
      "requestBody": {
        "key": "requestBody",
        "value": {
          "stringValue": "$sub_integration_input$"
        }
      },
      "followRedirects": {
        "key": "followRedirects",
        "value": {
          "booleanValue": true
        }
      },
      "additionalHeaders": {
        "key": "additionalHeaders"
      }
    },
    "taskExecutionStrategy": "WHEN_ALL_SUCCEED",
    "displayName": "Call REST Endpoint",
    "externalTaskType": "NORMAL_TASK",
    "position": {
      "x": 210,
      "y": 42
    }
  }],
  "integrationParameters": [{
    "key": "total_order_value",
    "dataType": "DOUBLE_VALUE",
    "displayName": "total_order_value",
    "inputOutputType": "OUT"
  }, {
    "key": "`Task_4_loopMetadata`",
    "dataType": "JSON_VALUE",
    "displayName": "`Task_4_loopMetadata`",
    "isTransient": true,
    "producer": "1_4"
  }, {
    "key": "threshold_order_value",
    "dataType": "DOUBLE_VALUE",
    "defaultValue": {
      "doubleValue": 100.0
    },
    "displayName": "threshold_order_value"
  }, {
    "key": "filtered_external_items",
    "dataType": "JSON_VALUE",
    "displayName": "filtered_external_items",
    "inputOutputType": "OUT"
  }, {
    "key": "orders_request",
    "dataType": "JSON_VALUE",
    "defaultValue": {
      "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\": 1.0\n  }]\n}"
    },
    "displayName": "orders_request",
    "inputOutputType": "IN",
    "jsonSchema": "{\n  \"properties\": {\n    \"buyer_id\": {\n      \"type\": \"string\"\n    },\n    \"line_items\": {\n      \"items\": {\n        \"properties\": {\n          \"price_per_unit\": {\n            \"type\": \"number\"\n          },\n          \"sku\": {\n            \"type\": \"string\"\n          },\n          \"vendor\": {\n            \"type\": \"string\"\n          },\n          \"line\": {\n            \"type\": \"number\"\n          },\n          \"quantity\": {\n            \"type\": \"number\"\n          }\n        },\n        \"type\": \"object\"\n      },\n      \"type\": \"array\"\n    },\n    \"order_no\": {\n      \"type\": \"string\"\n    }\n  },\n  \"type\": \"object\",\n  \"$schema\": \"http://json-schema.org/draft-04/schema#\"\n}"
  }, {
    "key": "rest_call_response_status",
    "dataType": "STRING_ARRAY",
    "displayName": "rest_call_response_status",
    "inputOutputType": "OUT"
  }, {
    "key": "`Task_2_isApproved`",
    "dataType": "BOOLEAN_VALUE",
    "displayName": "`Task_2_isApproved`",
    "isTransient": true,
    "producer": "1_2"
  }, {
    "key": "`Task_6_responseHeader`",
    "dataType": "STRING_VALUE",
    "displayName": "`Task_6_responseHeader`",
    "isTransient": true,
    "producer": "1_6"
  }, {
    "key": "`Task_6_responseBody`",
    "dataType": "STRING_VALUE",
    "displayName": "`Task_6_responseBody`",
    "isTransient": true,
    "producer": "1_6"
  }, {
    "key": "`Task_6_responseStatus`",
    "dataType": "STRING_VALUE",
    "defaultValue": {
      "stringValue": ""
    },
    "displayName": "`Task_6_responseStatus`",
    "inputOutputType": "OUT",
    "isTransient": true,
    "producer": "1_6"
  }, {
    "key": "orders_response",
    "dataType": "JSON_VALUE",
    "displayName": "orders_response",
    "inputOutputType": "OUT"
  }, {
    "key": "sub_integration_input",
    "dataType": "JSON_VALUE",
    "defaultValue": {
      "jsonValue": "{\n}"
    },
    "displayName": "sub_integration_input",
    "inputOutputType": "IN"
  }]
}

샘플 통합 흐름

다음 이미지는 이 통합 코드 샘플에 대한 통합 편집기의 샘플 레이아웃을 보여줍니다.

샘플 통합 흐름을 보여주는 이미지 샘플 통합 흐름을 보여주는 이미지

샘플 통합 업로드 및 실행

샘플 통합을 업로드하고 실행하려면 다음 단계를 수행합니다.

  1. 통합 샘플을 .json 파일로 시스템에 저장합니다.
  2. Google Cloud 콘솔에서 Application Integration 페이지로 이동합니다.

    Application Integration으로 이동

  3. 탐색 메뉴에서 통합을 클릭합니다. 통합 목록 페이지가 나타납니다.
  4. 기존 통합을 선택하거나 통합 만들기를 클릭하여 새 통합을 만듭니다.

    새 통합을 만드는 경우:

    1. 통합 만들기 대화상자에 이름과 설명을 입력합니다.
    2. 통합 리전을 선택합니다.
    3. 통합을 위한 서비스 계정을 선택합니다. 통합 툴바의 통합 요약 창에서 언제든지 통합에 대한 서비스 계정 세부정보를 변경하거나 업데이트할 수 있습니다.
    4. 만들기를 클릭합니다.

    통합 편집기 페이지에서 통합이 열립니다.

  5. 통합 편집기에서 업로드/다운로드 메뉴를 클릭한 후 통합 업로드를 선택합니다.
  6. 파일 브라우저 대화상자에서 1단계에서 저장한 파일을 선택한 후 열기를 클릭합니다.

    업로드된 파일을 통해 새 버전의 통합이 생성됩니다.

  7. 통합 편집기에서 테스트를 클릭합니다.
  8. 통합 테스트를 클릭합니다. 그러면 통합이 실행되고 통합 테스트 대화상자에 실행 결과가 표시됩니다.