使用Flow Service API為Zendesk建立資料流
下列教學課程會逐步引導您完成建立來源連線和資料流的步驟,以使用Flow Service API將Zendesk資料帶入Platform。
快速入門
本指南需要您實際瞭解下列Experience Platform元件:
下列章節提供您需瞭解的其他資訊,才能使用Flow Service API成功連線到Zendesk。
收集必要的認證
若要在Platform上存取您的Zendesk帳戶,您必須提供下列認證的值:
subdomain
https://yoursubdomain.zendesk.com
accessToken
0lZnClEvkJSTQ7olGLl7PMhVq99gu26GTbJtf
如需驗證Zendesk來源的詳細資訊,請參閱Zendesk 來源概觀。
使用Flow Service API連線Zendesk至平台
下列教學課程會逐步引導您完成建立Zendesk來源連線與建立資料流的步驟,以使用Flow Service API將Zendesk資料帶入Platform。
建立基礎連線 base-connection
基礎連線會保留您的來源和平台之間的資訊,包括來源的驗證認證、連線的目前狀態,以及您唯一的基本連線ID。 基礎連線ID可讓您從來源內部探索及導覽檔案,並識別您要擷取的特定專案,包括其資料型別和格式的資訊。
若要建立基底連線ID,請在提供您的Zendesk驗證認證作為要求內文的一部分時,向/connections
端點提出POST要求。
API格式
POST /connections
要求
下列要求會建立Zendesk的基礎連線:
curl -X POST \
'https://platform.adobe.io/data/foundation/flowservice/connections' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Content-Type: application/json' \
-d '{
"name": "Zendesk base connection",
"description": "Zendesk base connection to authenticate to Platform",
"connectionSpec": {
"id": "0a27232b-2c6e-4396-b8c6-c9fc24e37ba4",
"version": "1.0"
},
"auth": {
"specName": "OAuth2 Refresh Code",
"params": {
"subdomain": "{SUBDOMAIN}",
"accessToken": "{ACCESS_TOKEN}"
}
}
}'
name
description
connectionSpec.id
auth.specName
auth.params.
auth.params.subdomain
https://yoursubdomain.zendesk.com
。auth.params.accessToken
回應
成功的回應會傳回新建立的基礎連線,包括其唯一的連線識別碼(id
)。 在下一步中探索來源的檔案結構和內容時,需要此ID。
{
"id": "70383d02-2777-4be7-a309-9dd6eea1b46d",
"etag": "\"d64c8298-add4-4667-9a49-28195b2e2a84\""
}
探索您的來源 explore
使用您在上一步中產生的基本連線ID,您可以透過執行GET請求來探索檔案和目錄。
使用以下呼叫來尋找您要帶入Platform的檔案路徑:
API格式
GET /connections/{BASE_CONNECTION_ID}/explore?objectType=rest&object={OBJECT}&fileType={FILE_TYPE}&preview={PREVIEW}&sourceParams={SOURCE_PARAMS}
執行GET請求以探索來源的檔案結構和內容時,您必須包括下表列出的查詢引數:
{BASE_CONNECTION_ID}
objectType=rest
rest
。{OBJECT}
fileType=json
json
是唯一受支援的檔案型別。{PREVIEW}
{SOURCE_PARAMS}
{SOURCE_PARAMS}
接受的格式型別,您必須以base64編碼整個parameter
字串。 在下列範例中,以base64編碼的"{}"
等於e30
。要求
curl -X GET \
'https://platform.adobe.io/data/foundation/flowservice/connections/70383d02-2777-4be7-a309-9dd6eea1b46d/explore?objectType=rest&object=json&fileType=json&preview=true&sourceParams=e30' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
回應
成功的回應會傳回查詢檔案的結構。 在以下範例中,data[]
裝載中只顯示單一記錄,但可能有多個記錄。
{
"format": "hierarchical",
"schema": {
"type": "object",
"properties": {
"result": {
"type": "object",
"properties": {
"organization_id": {
"type": "integer",
"minimum": -9007199254740992,
"maximum": 9007199254740991
},
"external_id": {
"type": "integer",
"minimum": -9007199254740992,
"maximum": 9007199254740991
},
"role_type": {
"type": "integer",
"minimum": -9007199254740992,
"maximum": 9007199254740991
},
"custom_role_id": {
"type": "integer",
"minimum": -9007199254740992,
"maximum": 9007199254740991
},
"default_group_id": {
"type": "integer",
"minimum": -9007199254740992,
"maximum": 9007199254740991
},
"phone": {
"type": "string"
},
"shared_phone_number": {
"type": "boolean"
},
"alias": {
"type": "string"
},
"last_login_at": {
"type": "string"
},
"signature": {
"type": "string"
},
"details": {
"type": "string"
},
"notes": {
"type": "string"
},
"photo": {
"type": "string",
"media": {
"binaryEncoding": "base64",
"type": "image/png"
}
},
"active": {
"type": "boolean"
},
"created_at": {
"type": "string"
},
"email": {
"type": "string"
},
"iana_time_zone": {
"type": "string"
},
"id": {
"type": "integer"
},
"locale": {
"type": "string"
},
"locale_id": {
"type": "integer"
},
"moderator": {
"type": "boolean"
},
"name": {
"type": "string"
},
"only_private_comments": {
"type": "boolean"
},
"report_csv": {
"type": "boolean"
},
"restricted_agent": {
"type": "boolean"
},
"result_type": {
"type": "string"
},
"role": {
"type": "integer"
},
"shared": {
"type": "boolean"
},
"shared_agent": {
"type": "boolean"
},
"suspended": {
"type": "boolean"
},
"ticket_restriction": {
"type": "string"
},
"time_zone": {
"type": "string"
},
"two_factor_auth_enabled": {
"type": "boolean"
},
"updated_at": {
"type": "string"
},
"url": {
"type": "string"
},
"verified": {
"type": "boolean"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
},
"data": [
{
"result": {
"id": 6106699702801,
"url": "https://{YOURSUBDOMAIN}.zendesk.com/api/v2/users/6106699702801.json",
"name": "test",
"email": "test@org.com",
"created_at": "2022-05-13T08:04:22Z",
"updated_at": "2022-05-13T08:04:22Z",
"time_zone": "Asia/Kolkata",
"iana_time_zone": "Asia/Kolkata",
"locale_id": 1,
"locale": "en-US",
"role": "end-user",
"verified": false,
"active": true,
"shared": false,
"shared_agent": false,
"two_factor_auth_enabled": false,
"moderator": false,
"ticket_restriction": "requested",
"only_private_comments": false,
"restricted_agent": true,
"suspended": false,
"report_csv": false,
"result_type": "user"
}
}
]
}
建立來源連線 source-connection
您可以向Flow Service API發出POST要求,以建立來源連線。 來源連線由連線ID、來源資料檔案的路徑以及連線規格ID組成。
API格式
POST /sourceConnections
要求
下列要求會建立Zendesk的來源連線:
curl -X POST \
'https://platform.adobe.io/data/foundation/flowservice/sourceConnections' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Content-Type: application/json' \
-d '{
"name": "Zendesk Source Connection",
"description": "Zendesk Source Connection",
"baseConnectionId": "70383d02-2777-4be7-a309-9dd6eea1b46d",
"connectionSpec": {
"id": "0a27232b-2c6e-4396-b8c6-c9fc24e37ba4",
"version": "1.0"
},
"data": {
"format": "json"
},
"params": {}
}'
name
description
baseConnectionId
connectionSpec.id
data.format
json
。回應
成功的回應會傳回新建立的來源連線的唯一識別碼(id
)。 在後續步驟中需要此ID才能建立資料流。
{
"id": "246d052c-da4a-494a-937f-a0d17b1c6cf5",
"etag": "\"712a8c08-fda7-41c2-984b-187f823293d8\""
}
建立目標XDM結構描述 target-schema
為了在Platform中使用來源資料,必須建立目標結構描述,以根據您的需求來建構來源資料。 然後目標結構描述會用來建立包含來源資料的Platform資料集。
可透過對結構描述登入API執行POST要求來建立目標XDM結構描述。
如需有關如何建立目標XDM結構描述的詳細步驟,請參閱有關使用API 建立結構描述的教學課程。
建立目標資料集 target-dataset
可以透過對目錄服務API執行POST要求,在承載中提供目標結構描述的ID來建立目標資料集。
如需有關如何建立目標資料集的詳細步驟,請參閱有關使用API建立資料集的教學課程。
建立目標連線 target-connection
目標連線代表與要儲存所擷取資料的目的地之間的連線。 若要建立目標連線,您必須提供對應至資料湖的固定連線規格ID。 此ID為: c604ff05-7f1a-43c0-8e18-33bf874cb11c
。
您現在具有目標結構描述、目標資料集和到資料湖的連線規格ID的唯一識別碼。 使用這些識別碼,您可以使用Flow Service API建立目標連線,以指定將包含傳入來源資料的資料集。
API格式
POST /targetConnections
要求
以下請求會建立Zendesk的目標連線:
curl -X POST \
'https://platform.adobe.io/data/foundation/flowservice/targetConnections' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Content-Type: application/json' \
-d '{
"name": "Zendesk Target Connection",
"description": "Zendesk Target Connection",
"connectionSpec": {
"id": "c604ff05-7f1a-43c0-8e18-33bf874cb11c",
"version": "1.0"
},
"data": {
"format": "json"
},
"params": {
"dataSetId": "624bf42e16519d19496e3f67"
}
}'
name
description
connectionSpec.id
c604ff05-7f1a-43c0-8e18-33bf874cb11c
。data.format
params.dataSetId
回應
成功的回應會傳回新目標連線的唯一識別碼(id
)。 此ID在後續步驟中是必要的。
{
"id": "7c96c827-3ffd-460c-a573-e9558f72f263",
"etag": "\"a196f685-f5e8-4c4c-bfbd-136141bb0c6d\""
}
建立對應 mapping
為了將來源資料擷取到目標資料集中,必須首先將其對應到目標資料集所堅持的目標結構描述。 這是透過透過使用在要求裝載中定義的資料對應對Data Prep API執行POST要求來達成。
API格式
POST /conversion/mappingSets
要求
curl -X POST \
'https://platform.adobe.io/data/foundation/conversion/mappingSets' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Content-Type: application/json' \
-d '{
"version": 0,
"xdmSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/995dabbea86d58e346ff91bd8aa741a9f36f29b1019138d4",
"xdmVersion": "1.0",
"mappings": [
{
"sourceType": "ATTRIBUTE",
"source": "result.id",
"destination": "_extconndev.id",
"name": "id",
"description": "Zendesk"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.external_id",
"destination": "_extconndev.external_id"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.role_type",
"destination": "_extconndev.role_type"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.custom_role_id",
"destination": "_extconndev.custom_role_id"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.default_group_id",
"destination": "_extconndev.default_group_id"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.phone",
"destination": "_extconndev.phone"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.shared_phone_number",
"destination": "_extconndev.shared_phone_number"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.verified",
"destination": "_extconndev.verified"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.alias",
"destination": "_extconndev.alias"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.last_login_at",
"destination": "_extconndev.last_login_at"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.signature",
"destination": "_extconndev.signature"
}, {
"sourceType": "ATTRIBUTE",
"source": "result.details",
"destination": "_extconndev.details"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.notes",
"destination": "_extconndev.notes"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.active",
"destination": "_extconndev.active"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.created_at",
"destination": "_extconndev.created_at"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.email",
"destination": "_extconndev.email"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.iana_time_zone",
"destination": "_extconndev.iana_time_zone"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.organization_id",
"destination": "_extconndev.organization_id"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.locale",
"destination": "_extconndev.locale"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.locale_id",
"destination": "_extconndev.locale_id"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.moderator",
"destination": "_extconndev.moderator"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.name",
"destination": "_extconndev.name"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.only_private_comments",
"destination": "_extconndev.only_private_comments"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.report_csv",
"destination": "_extconndev.report_csv"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.restricted_agent",
"destination": "_extconndev.restricted_agent"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.result_type",
"destination": "_extconndev.result_type"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.role",
"destination": "_extconndev.role"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.shared",
"destination": "_extconndev.shared"
}, {
"sourceType": "ATTRIBUTE",
"source": "result.shared_agent",
"destination": "_extconndev.shared_agent"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.time_zone",
"destination": "_extconndev.time_zone"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.two_factor_auth_enabled",
"destination": "_extconndev.two_factor_auth_enabled"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.suspended",
"destination": "_extconndev.suspended"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.updated_at",
"destination": "_extconndev.updated_at"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.url",
"destination": "_extconndev.url"
},
{
"sourceType": "ATTRIBUTE",
"source": "result.verified",
"destination": "_extconndev.verified"
}
]
}'
xdmSchema
mappings.destinationXdmPath
mappings.sourceAttribute
mappings.identity
回應
成功的回應會傳回新建立的對應詳細資料,包括其唯一識別碼(id
)。 在後續步驟中需要此值,才能建立資料流。
{
"id": "bf5286a9c1ad4266baca76ba3adc9366",
"version": 0,
"createdDate": 1597784069368,
"modifiedDate": 1597784069368,
"createdBy": "{CREATED_BY}",
"modifiedBy": "{MODIFIED_BY}"
}
建立流程 flow
將資料從Zendesk引進Platform的最後一步是建立資料流。 到現在為止,您已準備下列必要值:
資料流負責從來源排程及收集資料。 您可以執行POST要求,同時在裝載中提供先前提到的值,藉此建立資料流。
若要排程內嵌,您必須先將開始時間值設為以秒為單位的epoch時間。 然後,您必須將頻率值設定為下列五個選項之一: once
、minute
、hour
、day
或week
。 間隔值會指定兩個連續擷取之間的期間,不過,建立一次性擷取不需要設定間隔。 對於所有其他頻率,間隔值必須設定為等於或大於15
。
API格式
POST /flows
要求
curl -X POST \
'https://platform.adobe.io/data/foundation/flowservice/flows' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Content-Type: application/json' \
-d '{
"name": "Zendesk dataflow",
"description": "Zendesk dataflow",
"flowSpec": {
"id": "6499120c-0b15-42dc-936e-847ea3c24d72",
"version": "1.0"
},
"sourceConnectionIds": [
"246d052c-da4a-494a-937f-a0d17b1c6cf5"
],
"targetConnectionIds": [
"7c96c827-3ffd-460c-a573-e9558f72f263"
],
"transformations": [
{
"name": "Mapping",
"params": {
"mappingId": "bf5286a9c1ad4266baca76ba3adc9366",
"mappingVersion": "0"
}
}
],
"scheduleParams": {
"startTime": "1625040887",
"frequency": "minute",
"interval": 15
}
}'
name
description
flowSpec.id
6499120c-0b15-42dc-936e-847ea3c24d72
。flowSpec.version
1.0
。sourceConnectionIds
targetConnectionIds
transformations
transformations.name
transformations.params.mappingId
transformations.params.mappingVersion
0
。scheduleParams.startTime
scheduleParams.frequency
once
、minute
、hour
、day
或week
。scheduleParams.interval
once
時不需要間隔,其他頻率值應該大於或等於15
。回應
成功的回應會傳回新建立的資料流識別碼(id
)。 您可以使用此ID來監視、更新或刪除資料流。
{
"id": "993f908f-3342-4d9c-9f3c-5aa9a189ca1a",
"etag": "\"510bb1d4-8453-4034-b991-ab942e11dd8a\""
}
附錄
下節提供監視、更新和刪除資料流的步驟相關資訊。
監視資料流
建立資料流後,您可以監視透過該資料流擷取的資料,以檢視有關資料流執行、完成狀態和錯誤的資訊。 如需完整的API範例,請閱讀使用API監視您的來源資料流的指南。
更新您的資料流
提供資料流的ID時,藉由向Flow Service API的/flows
端點發出PATCH要求,更新資料流的詳細資訊,例如其名稱和說明,以及其執行排程和相關聯的對應集。 提出PATCH要求時,您必須在If-Match
標頭中提供資料流的唯一etag
。 如需完整的API範例,請閱讀使用API更新來源資料流的指南。
更新您的帳戶
在提供您的基本連線ID作為查詢引數的同時,透過對Flow Service API執行PATCH請求來更新來源帳戶的名稱、說明和認證。 發出PATCH要求時,您必須在If-Match
標頭中提供來源帳戶的唯一etag
。 如需完整的API範例,請閱讀使用API更新來源帳戶的指南。
刪除您的資料流
提供您要刪除之資料流的ID做為查詢引數的一部分,同時對Flow Service API執行DELETE要求,以刪除您的資料流。 如需完整的API範例,請閱讀使用API刪除資料流的指南。
刪除您的帳戶
在提供您要刪除之帳戶的基本連線ID時,透過對Flow Service API執行DELETE要求來刪除帳戶。 如需完整的API範例,請閱讀使用API刪除來源帳戶的指南。