我已经构建了一条消息,该消息要从 js 模块中生成的有效负载中以 slack 的形式返回。该消息在块工具包构建器中被格式化为:
{
"blocks": [
{
"type": "section",
"text": {
"text": "Tides for *Aberdeen* on _Saturday, 5th February 2023 (GMT)_",
"type": "mrkdwn"
},
"fields": [
{
"type": "mrkdwn",
"text": "*Time*"
},
{
"type": "mrkdwn",
"text": "*Height*"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "For multiple days and tide height predictions use <https://script.google.com/macros/s/AKfycbwdzfkbP-YiBD0r7moZ80MrjgU68CYQ-pNqm8YbPoDQd_iSOk7vGOxV7xBdZrxQSzsafQ/exec|:uktides: Uk Tides>."
}
}
]
}
这在块套件构建器中提供了以下内容:
但是,当应用程序运行时,返回的有效负载显示为:
即格式以某种方式被忽略。
我的代码的相关部分是:
var payload = {
"blocks": [
{
"type": "section",
"text": {
"text": "Tides for *Aberdeen* on _Saturday, 5th February 2023 (GMT)_",
"type": "mrkdwn"
},
"fields": [
{
"type": "mrkdwn",
"text": "*Time*"
},
{
"type": "mrkdwn",
"text": "*Height*"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "For multiple days and tide height predictions use <https://script.google.com/macros/s/AKfycbwdzfkbP-YiBD0r7moZ80MrjgU68CYQ-pNqm8YbPoDQd_iSOk7vGOxV7xBdZrxQSzsafQ/exec|:uktides: Uk Tides>."
}
}
]
}
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET,
socketMode: true,
appToken: process.env.SLACK_APP_TOKEN,
// Socket Mode doesn't listen on a port, but in case you want your app to respond to OAuth,
// you still need to listen on some port!
port: process.env.PORT || 3000,
extendedErrorHandler: true
});
// Listens to incoming messages that contain "hello"
app.message('hello', async ({ message, say }) => {
// say() sends a message to the channel where the event was triggered
await say(`Hey there <@${message.user}>! my name is Ollie 2.1, how can I help you?`);
});
app.command('/tides', async ({ command, ack, say, respond }) => {
// Acknowledge command request
await ack();
await parseCommand(`${command.text}`);
await say(JSON.stringify(payload));
//await respond(`${command.text}`);
});
谁能看到我做错了什么?
谢谢。