2

我正在尝试制作一个节点松弛机器人。当我从 Slack 出发时,

app.get('/testbot', testbot);

我打电话给测试机器人:

测试机器人.js:

postToSlack(botPayload, function (error, status, body) {
     console.log('successfully posted to slack');
});

我将我的有效负载对象发布到他们的Slack API中指定的 Webhook URL :“ https://hooks.slack.com/services/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

function postToSlack (payload, callback) {
    var val = JSON.stringify(payload);
    request({
        uri: 'https://hooks.slack.com/services/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&payload=val',
        method: 'POST'
    }, function (error, response, body) {
        if (error) {
            return callback(error);
        }
        console.log('RESPONSE', body); //takes forever, then eventually comes back as { }
        callback(null, response.statusCode, body);
    });
}

console.log('RESPONSE', body)不返回任何东西。

我的测试 botPayload 对象如下所示:

var botPayload = {};
botPayload.text = 'This should be working';
botPayload.username = 'my_new_bot';
botPayload.channel = '#mychannel';
botPayload.icon_url = 'http://i.imgur.com/IciaiJt.png';

我在这里做错了什么?


如何从帖子中删除 BOT 标签?

在此处输入图像描述

4

0 回答 0