I have a problem, probably stupid one, with slack slash command.
I config a /command that simple ask some data about covid infection that will be fetch at request, the answer work well but after some second (3000 ms for timeout) i have a message of error "failed with the error "operation_timeout".
Reading Slack documentation i must send a post message of confirmation and this i think is done by sending Post response with message, right? or i must send an answer before send the message?
This is the code:
app.post('/covid', async (req, res) => {
console.log(req.body)
const respUrl = req.body.response_url
slackBody = {
"text": "Test"
}
await axios.post(respUrl, JSON.stringify(slackBody), {
headers: {
'Content-Type': 'application/json',
}
})
.then(function (response) {
console.log(response.data);
console.log(response.status);
console.log(response.statusText);
console.log(response.headers);
console.log(response.config);
})
.catch((e) => console.log(e))
})
And this is the Axios response.
{
url: 'https://hooks.slack.com/commands/TU7AFJ1RU/1022360678069/tTuQ4NJhgmnb58FNPeubZUR5',
method: 'post',
data: '{"text":"Test"}',
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
'User-Agent': 'axios/0.19.2',
'Content-Length': 15
},
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
adapter: [Function: httpAdapter],
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: [Function: validateStatus]
}
I'm breaking my head from 8hour for this tricky issue. Thanks for your help :)
UPDATE
Dear community i resolve this issue with simple
res.send(slackBody)
deleting all axios config, now i have plain message, also if i send object Block the slack visualize Array and not the message...