2017-07-22 27 views
3

在Azure中使用Logic App将消息发布到冗余。这适用于标准文本消息。 当我改变也张贴附件没有被发送:Azure Logic App不会将附件发送到零散地址

    "inputs": { 
         "host": { 
          "connection": { 
           "name": "@parameters('$connections')['slack']['connectionId']" 
          } 
         }, 
         "method": "post", 
         "path": "/chat.postMessage", 
         "queries": { 
          "attachments": [ 
           { 
            "color": "danger", 
            "fallback": "Azure alert attachment.", 
            "fields": [ 
             { 
              "title": "Check list" 
             }, 
             { 
              "value": "Check services on VM0 and VM1" 
             }, 
             { 
              "value": "If you cannot fix this issue make sure someone else can" 
             } 
            ], 
            "pretext": "<!channel> Action required", 
            "text": "`'@{triggerBody()['context']['name']}'` API down - '@{triggerBody()['context']['resourceName']}' Details: @{body('Http')['id']}", 
            "ts": 123456789 
           } 
          ], 
          "channel": "#devops", 
          "text": "SYST ALERT" 
         } 
        } 
+0

你有没有发现这是怎么回事?我目前面临同样的问题,无法解决如何解决这个问题。 – Andrew

回答

0

展望这一点,似乎逻辑Apps不支持的附件类型。请UserVoice的给予好评@

https://feedback.azure.com/forums/287593-logic-apps/suggestions/31896379-add-support-for-attachments-with-slack-post-messag

所以有了这样的情况下,我们怎么今天这样做。 Slack支持传入的Webhook以及API。我使用chat.PostMessage API进行的API看起来更详细信息在启用这个在逻辑应用程序:

https://api.slack.com/methods/chat.postMessage/test

这种方法的基本问题是一个令牌的要求,我的样品i中使用的测试令牌从

https://api.slack.com/custom-integrations/legacy-tokens

这是不是最好的方法(但我在使用传入网络挂接将继续尝试这种方法,并张贴如果我有成功,有一些问题),从安全POV但落榜完成。最终工作代码如下:

{ 
    "$connections": { 
     "value": { 
      "office365": { 
       "connectionId": "<ConnectionID", 
       "connectionName": "office365", 
       "id": "<ID>" 
      } 
     } 
    }, 
    "definition": { 
     "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", 
     "actions": { 
      "Condition_3": { 
       "actions": { 
        "HTTP": { 
         "inputs": { 
          "body": "?token=<Token>&channel=C8270DY6L&attachments=%5B%7B%22fallback%22%3A%22Requiredplain-textsummaryoftheattachment.%22%2C%22color%22%3A%22%2336a64f%22%2C%22pretext%22%3A%22Optionaltextthatappearsabovetheattachmentblock%22%2C%22author_name%22%3A%22BobbyTables%22%2C%22author_link%22%3A%22http%3A%2F%2Fflickr.com%2Fbobby%2F%22%2C%22author_icon%22%3A%22http%3A%2F%2Fflickr.com%2Ficons%2Fbobby.jpg%22%2C%22title%22%3A%22SlackAPIDocumentation%22%2C%22title_link%22%3A%22https%3A%2F%2Fapi.slack.com%2F%22%2C%22text%22%3A%22Optionaltextthatappearswithintheattachment%22%2C%22fields%22%3A%5B%7B%22title%22%3A%22Priority%22%2C%22value%22%3A%22High%22%2C%22short%22%3Afalse%7D%5D%2C%22image_url%22%3A%22http%3A%2F%2Fmy-website.com%2Fpath%2Fto%2Fimage.jpg%22%2C%22thumb_url%22%3A%22http%3A%2F%2Fexample.com%2Fpath%2Fto%2Fthumb.png%22%2C%22footer%22%3A%22SlackAPI%22%2C%22footer_icon%22%3A%22https%3A%2F%2Fplatform.slack-edge.com%2Fimg%2Fdefault_application_icon.png%22%2C%22ts%22%3A123456789%7D%5D&pretty=1", 
          "method": "POST", 
          "uri": "https://slack.com/api/chat.postMessage" 
         }, 
         "runAfter": {}, 
         "type": "Http" 
        } 
       }, 
       "expression": "@equals(triggerBody()?['HasAttachment'], True)", 
       "runAfter": {}, 
       "type": "If" 
      } 
     }, 
     "contentVersion": "1.0.0.0", 
     "outputs": {}, 
     "parameters": { 
      "$connections": { 
       "defaultValue": {}, 
       "type": "Object" 
      } 
     }, 
     "triggers": { 
      "When_a_new_email_arrives": { 
       "inputs": { 
        "host": { 
         "connection": { 
          "name": "@parameters('$connections')['office365']['connectionId']" 
         } 
        }, 
        "method": "get", 
        "path": "/Mail/OnNewEmail", 
        "queries": { 
         "folderPath": "Inbox", 
         "importance": "Normal" 
        } 
       }, 
       "recurrence": { 
        "frequency": "Minute", 
        "interval": 3 
       }, 
       "splitOn": "@triggerBody()?['value']", 
       "type": "ApiConnection" 
      } 
     } 
    } 
} 
相关问题