如何创建逻辑应用程序以从松弛频道复制图片?
How do I create a logic app to copy pictures from slack channel?
我想自动复制到达松弛通道以转到 Azure Blob 的图片。
我找到了 some docs on connecting to Slack
并且能够创建一个 When File Is Created 任务
接下来我尝试的是复制 blob 步骤。然而这似乎不对。
[更新]
在 George 的帮助下,我添加了 HTTP 任务。
这是我在 Slack 触发器的代码视图中看到的内容
或修改后的文本格式
{
"$connections": {
"value": {
"slack_1": {
"connectionId": "/subscriptions/subscriptionid/resourceGroups/SlackPicToBlob/providers/Microsoft.Web/connections/slack-1",
"connectionName": "slack-1",
"id": "/subscriptions/subscriptionid/providers/Microsoft.Web/locations/australiasoutheast/managedApis/slack"
}
}
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"When_a_file_is_created": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['slack_1']['connectionId']"
}
},
"method": "get",
"path": "/trigger/files.list",
"queries": {
"channel": "CMRUVPHS5"
}
},
"recurrence": {
"frequency": "Minute",
"interval": 3
},
"splitOn": "@triggerBody()",
"type": "ApiConnection"
}
}
}
}
[更新]
我 运行 任务,现在理解乔治关于使用 Slack 中的菜单创建 link 的说明。
创建 link 后出现以下错误。
No output
查看 运行 历史记录,HTTP 原始输入是
{
"uri": "https://files.slack.com/files-pri/TMLT14MDH-FN842SZD3/img_20190911_175347.jpg?pub_secret=3b49994016",
"method": "GET"
}
原始输出是
{
"statusCode": 302,
"headers": {
"Connection": "keep-alive",
"X-Backend": "supra-prod-syd-7d7dc657-m6t8j",
"X-Slack-Meta": "?;proxy_redir",
"X-Cache": "Miss from cloudfront",
"X-Amz-Cf-Pop": "MEL50",
"X-Amz-Cf-Id": "T8AsYDMMGWkO12pi97bvgfJzkxjXu5F_4cMOalyH9NQutxEpi8OseQ==",
"Date": "Wed, 11 Sep 2019 07:56:13 GMT",
"Location": "https://jobtalk-workspace.slack.com/?redir=%2Ffiles-pri%2FTMLT14MDH-FN842SZD3%2Fimg_20190911_175347.jpg%3Fpub_secret%3D3b49994016",
"Via": "1.1 2f3f099f90ecec674faf8faec5c60de1.cloudfront.net (CloudFront)",
"Content-Length": "152",
"Content-Type": "text/html; charset=utf-8"
},
"body": "<a href=\"https://jobtalk-workspace.slack.com/?redir=%2Ffiles-pri%2FTMLT14MDH-FN842SZD3%2Fimg_20190911_175347.jpg%3Fpub_secret%3D3b49994016\">Found</a>.\n\n"
}
创建 blob 任务显示错误消息
ActionConditionFailed. The execution of template action 'Create_blob'
is skipped: the 'runAfter' condition for action 'HTTP' is not
satisfied. Expected status values 'Succeeded' and actual value
'Failed'.
创建 blob 任务显示错误消息
ActionConditionFailed. The execution of template action 'Create_blob'
is skipped: the 'runAfter' condition for action 'HTTP' is not
satisfied. Expected status values 'Succeeded' and actual value
'Failed'.
[更新]
在我创建外部 link 之后,我能够让任务通过。
然而,blob 并未到达存储空间。
我想我需要一个步骤来下载文件。
我正在关注 this question 寻求帮助。
您无法使用松弛触发器创建 blob,因为触发器响应不包含文件,检查 slack trigger 您会发现它只有 return 一些文件信息和一些 link秒。会像下图那样。
因此您必须使用 HTTP GET 操作从 link 获取图片。而且这不是return the external link(因为默认不会创建external link),所以你还需要在上传文件后创建external link .
而默认的外部link与url_private和permalink_public中的pub_secret组合在一起,所以HTTP GET url输入将是这样的
@{triggerBody()['url_private']}?pub_secret=@{substring(triggerBody()['permalink_public'],44,10)}
所以我的流程如下图,你可以试试,如果还有问题,请随时告诉我。
我想自动复制到达松弛通道以转到 Azure Blob 的图片。
我找到了 some docs on connecting to Slack 并且能够创建一个 When File Is Created 任务
接下来我尝试的是复制 blob 步骤。然而这似乎不对。
[更新]
在 George 的帮助下,我添加了 HTTP 任务。
这是我在 Slack 触发器的代码视图中看到的内容
或修改后的文本格式
{
"$connections": {
"value": {
"slack_1": {
"connectionId": "/subscriptions/subscriptionid/resourceGroups/SlackPicToBlob/providers/Microsoft.Web/connections/slack-1",
"connectionName": "slack-1",
"id": "/subscriptions/subscriptionid/providers/Microsoft.Web/locations/australiasoutheast/managedApis/slack"
}
}
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"When_a_file_is_created": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['slack_1']['connectionId']"
}
},
"method": "get",
"path": "/trigger/files.list",
"queries": {
"channel": "CMRUVPHS5"
}
},
"recurrence": {
"frequency": "Minute",
"interval": 3
},
"splitOn": "@triggerBody()",
"type": "ApiConnection"
}
}
}
}
[更新]
我 运行 任务,现在理解乔治关于使用 Slack 中的菜单创建 link 的说明。
创建 link 后出现以下错误。
No output
查看 运行 历史记录,HTTP 原始输入是
{
"uri": "https://files.slack.com/files-pri/TMLT14MDH-FN842SZD3/img_20190911_175347.jpg?pub_secret=3b49994016",
"method": "GET"
}
原始输出是
{
"statusCode": 302,
"headers": {
"Connection": "keep-alive",
"X-Backend": "supra-prod-syd-7d7dc657-m6t8j",
"X-Slack-Meta": "?;proxy_redir",
"X-Cache": "Miss from cloudfront",
"X-Amz-Cf-Pop": "MEL50",
"X-Amz-Cf-Id": "T8AsYDMMGWkO12pi97bvgfJzkxjXu5F_4cMOalyH9NQutxEpi8OseQ==",
"Date": "Wed, 11 Sep 2019 07:56:13 GMT",
"Location": "https://jobtalk-workspace.slack.com/?redir=%2Ffiles-pri%2FTMLT14MDH-FN842SZD3%2Fimg_20190911_175347.jpg%3Fpub_secret%3D3b49994016",
"Via": "1.1 2f3f099f90ecec674faf8faec5c60de1.cloudfront.net (CloudFront)",
"Content-Length": "152",
"Content-Type": "text/html; charset=utf-8"
},
"body": "<a href=\"https://jobtalk-workspace.slack.com/?redir=%2Ffiles-pri%2FTMLT14MDH-FN842SZD3%2Fimg_20190911_175347.jpg%3Fpub_secret%3D3b49994016\">Found</a>.\n\n"
}
创建 blob 任务显示错误消息
ActionConditionFailed. The execution of template action 'Create_blob' is skipped: the 'runAfter' condition for action 'HTTP' is not satisfied. Expected status values 'Succeeded' and actual value 'Failed'.
创建 blob 任务显示错误消息
ActionConditionFailed. The execution of template action 'Create_blob' is skipped: the 'runAfter' condition for action 'HTTP' is not satisfied. Expected status values 'Succeeded' and actual value 'Failed'.
[更新]
在我创建外部 link 之后,我能够让任务通过。 然而,blob 并未到达存储空间。
我想我需要一个步骤来下载文件。
我正在关注 this question 寻求帮助。
您无法使用松弛触发器创建 blob,因为触发器响应不包含文件,检查 slack trigger 您会发现它只有 return 一些文件信息和一些 link秒。会像下图那样。
因此您必须使用 HTTP GET 操作从 link 获取图片。而且这不是return the external link(因为默认不会创建external link),所以你还需要在上传文件后创建external link .
而默认的外部link与url_private和permalink_public中的pub_secret组合在一起,所以HTTP GET url输入将是这样的
@{triggerBody()['url_private']}?pub_secret=@{substring(triggerBody()['permalink_public'],44,10)}
所以我的流程如下图,你可以试试,如果还有问题,请随时告诉我。