node.js - 如何在 Slack 附件的字段选项内添加 URL?

标签 node.js slack-api slack

我正在尝试从外部来源向 Slack channel 发送通知。我试图将 URL 链接放在附件的字段标记中。有办法吗?

{
    "attachments": [
        {
            "fallback": "Required plain-text summary of the attachment.",

            "color": "#36a64f",

            "pretext": "Optional text that appears above the attachment block",

            "author_name": "Bobby Tables",
            "author_link": "http://flickr.com/bobby/",
            "author_icon": "http://flickr.com/icons/bobby.jpg",

            "title": "Slack API Documentation",
            "title_link": "https://api.slack.com/",

            "text": "Optional text that appears within the attachment",

            "fields": [
                {
                    "title": "Priority",
                    "value": "High",
                    "short": false
                }
            ],

            "image_url": "http://my-website.com/path/to/image.jpg",
            "thumb_url": "http://example.com/path/to/thumb.png"
        }
    ]
}

最佳答案

是的,您可以在字段中使用 URL。但它只适用于 value 标签。您甚至可以在那里使用标记。

这是一个 PHP 示例:

$slack->addAttachment( array (
    "fallback" => "Fallback",
    "title" => "Title",
    "text" => "text",
    "fields" => array (
        array (
            "title" => "Priority",
            "value" => "<http://i.imgur.com/nwo13SM.png|test>",
            "short" => false
        )
        )
    ));

关于node.js - 如何在 Slack 附件的字段选项内添加 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35030496/

相关文章:

node.js - 如何使用 Babel 将 JSX 编译为 JavaScript

javascript - 从sequelize模型 'define'向sqlite添加约束

slack-api - Slack - 显示用户的全名而不是用户名

airflow - 显式跳过 DAG 时松弛通知

javascript - 如何张贴提及松弛传入的 webhooks

python - 尝试使用 RTM API 连接到 Slack 时出现 "Failed RTM connect"错误

angularjs - npm start 在设置 angular-seed 应用程序时返回错误 127

node.js - Yarn - Node Sass 还不支持我当前的环境

api - 使用 Chrome 身份验证 token xoxc- 访问 Slack API

jenkins - Jenkins 管道构建失败后如何发送 Slack 通知?