查看 Application Integration 支援的連接器

叫用子整合來傳送電子郵件

使用 For Each Loop 工作,叫用子整合功能,從主要整合功能取得輸入內容,然後傳送電子郵件通知。

程式碼範例:子整合

{
  "triggerConfigs": [{
    "label": "API Trigger",
    "startTasks": [{
      "taskId": "1"
    }],
    "properties": {
      "Trigger name": "SubIntegrationSendEmailDemo_API_1"
    },
    "triggerType": "API",
    "triggerNumber": "1",
    "triggerId": "api_trigger/SubIntegrationSendEmailDemo_API_1"
  }],
  "taskConfigs": [{
    "task": "EmailTask",
    "taskId": "1",
    "parameters": {
      "Cc": {
        "key": "Cc",
        "value": {
          "stringArray": {
          }
        }
      },
      "TextBody": {
        "key": "TextBody",
        "value": {
          "stringValue": "$EmailContent$"
        }
      },
      "Bcc": {
        "key": "Bcc",
        "value": {
          "stringArray": {
          }
        }
      },
      "AttachmentPath": {
        "key": "AttachmentPath",
        "value": {
          "stringArray": {
          }
        }
      },
      "To": {
        "key": "To",
        "value": {
          "stringArray": {
            "stringValues": ["$Recipients$"]
          }
        }
      },
      "BodyFormat": {
        "key": "BodyFormat",
        "value": {
          "stringValue": "text"
        }
      },
      "EmailConfigInput": {
        "key": "EmailConfigInput",
        "value": {
          "jsonValue": "{\n  \"@type\": \"type.googleapis.com/enterprise.crm.eventbus.proto.EmailConfig\"\n}"
        }
      },
      "Subject": {
        "key": "Subject",
        "value": {
          "stringValue": "$Email_Subject$"
        }
      }
    },
    "taskExecutionStrategy": "WHEN_ALL_SUCCEED",
    "displayName": "Send Email"
  }],
  "integrationParameters": [{
    "key": "EmailContent",
    "dataType": "STRING_VALUE",
    "defaultValue": {
      "stringValue": ""
    },
    "displayName": "EmailContent",
    "inputOutputType": "IN"
  }, {
    "key": "Recipients",
    "dataType": "STRING_VALUE",
    "defaultValue": {
      "stringValue": ""
    },
    "displayName": "Recipients",
    "inputOutputType": "IN"
  }, {
    "key": "Email_Subject",
    "dataType": "STRING_VALUE",
    "defaultValue": {
      "stringValue": ""
    },
    "displayName": "Email_Subject",
    "inputOutputType": "IN"
  }]
}

程式碼範例:主要整合

{
  "triggerConfigs": [{
    "label": "API Trigger",
    "startTasks": [{
      "taskId": "1"
    }],
    "properties": {
      "Trigger name": "ForEachLoopDemo_API_1"
    },
    "triggerType": "API",
    "triggerNumber": "1",
    "triggerId": "api_trigger/ForEachLoopDemo_API_1"
  }],
  "taskConfigs": [{
    "task": "SubWorkflowForEachLoopV2Task",
    "taskId": "1",
    "parameters": {
      "iterationElementMapping": {
        "key": "iterationElementMapping",
        "value": {
          "stringValue": "EmailContent"
        }
      },
      "aggregatorParameterMapping": {
        "key": "aggregatorParameterMapping"
      },
      "triggerId": {
        "key": "triggerId",
        "value": {
          "stringValue": "api_trigger/SubIntegrationSendEmailDemo_API_1"
        }
      },
      "loopMetadata": {
        "key": "loopMetadata",
        "value": {
          "stringArray": {
            "stringValues": ["$`Task_1_loopMetadata`$"]
          }
        }
      },
      "disableEucPropagation": {
        "key": "disableEucPropagation",
        "value": {
          "booleanValue": false
        }
      },
      "listToIterate": {
        "key": "listToIterate",
        "value": {
          "stringValue": "$ListOfEmailContent$"
        }
      },
      "workflowName": {
        "key": "workflowName",
        "value": {
          "stringValue": "SubIntegrationSendEmailDemo"
        }
      },
      "requestParameterMapping": {
        "key": "requestParameterMapping",
        "value": {
          "jsonValue": "{\n  \"@type\": \"type.googleapis.com/enterprise.crm.eventbus.proto.ParameterMap\",\n  \"entries\": [{\n    \"key\": {\n      \"literalValue\": {\n        \"stringValue\": \"Recipients\"\n      }\n    },\n    \"value\": {\n      \"literalValue\": {\n        \"stringValue\": \"Recipients\"\n      }\n    }\n  }, {\n    \"key\": {\n      \"literalValue\": {\n        \"stringValue\": \"Email_Subject\"\n      }\n    },\n    \"value\": {\n      \"literalValue\": {\n        \"stringValue\": \"Email_Subject\"\n      }\n    }\n  }]\n}"
        }
      },
      "overrideParameterMapping": {
        "key": "overrideParameterMapping"
      }
    },
    "taskExecutionStrategy": "WHEN_ALL_SUCCEED",
    "displayName": "For Each Loop"
  }],
  "integrationParameters": [{
    "key": "`Task_1_loopMetadata`",
    "dataType": "JSON_VALUE",
    "displayName": "`Task_1_loopMetadata`",
    "isTransient": true,
    "producer": "1_1"
  }, {
    "key": "Recipients",
    "dataType": "STRING_VALUE",
    "defaultValue": {
      "stringValue": ""
    },
    "displayName": "Recipients",
    "inputOutputType": "IN"
  }, {
    "key": "Email_Subject",
    "dataType": "STRING_VALUE",
    "defaultValue": {
      "stringValue": ""
    },
    "displayName": "Email_Subject",
    "inputOutputType": "IN"
  }, {
    "key": "ListOfEmailContent",
    "dataType": "STRING_ARRAY",
    "defaultValue": {
      "stringArray": {
        "stringValues": ["\"Content 1\"", "\"Content 2\"", "\"Content 3\"", "\"Content 4\""]
      }
    },
    "displayName": "ListOfEmailContent",
    "inputOutputType": "IN"
  }]
}

整合流程範例

下圖顯示這個整合程式碼範例的整合編輯器範例版面配置。

子整合

圖片:顯示範例子整合流程 圖片:顯示範例子整合流程

主要整合

圖片:顯示主要整合流程範例 圖片:顯示主要整合流程範例

上傳並執行範例整合功能

如要上傳及執行範例整合,請按照下列步驟操作:

  1. 整合範例儲存為系統中的 .json 檔案。
  2. 前往 Google Cloud 控制台的「Application Integration」頁面。

    前往「Application Integration」

  3. 按一下左側導覽選單中的「整合」,開啟「整合」頁面。
  4. 選取現有整合,或按一下「建立整合」建立新整合。

    如要建立新的整合項目:

    1. 在「建立整合」對話方塊中輸入名稱和說明。
    2. 選取整合作業的區域。
    3. 選取整合的服務帳戶。如要變更或更新整合的服務帳戶詳細資料,請隨時前往整合工具列的「整合摘要」窗格。
    4. 點選「建立」

    系統會在整合編輯器中開啟整合服務。

  5. 整合服務編輯器中,按一下「上傳/下載」選單 ,然後選取「上傳整合服務」
  6. 在檔案瀏覽器對話方塊中,選取您在步驟 1 中儲存的檔案,然後按一下「開啟」

    系統會使用上傳的檔案建立新的整合版本。

  7. 整合服務編輯器中,按一下「測試」
  8. 按一下「測試整合」。系統會執行整合項目,並在「Test Integration」(測試整合項目) 窗格中顯示執行結果。