Reputation: 163
I am developing a Slack bot using Bolt API in Node.js. The problem I am facing is when I send a slash command, the bot receives and responds to the command successfully but the command is not visible in the channel.
I read the following article https://api.slack.com/interactivity/slash-commands#responding_response_url where it states that I need to add {"response_type": "in_channel"}
slack.js
const { App, LogLevel } = require("@slack/bolt");
app.command("/ask", async ({ command, ack, say, respond }) => {
console.log("command ", command)
console.log("ack ", ack)
await ack();
await say(`Hi <@${command.user_name}>`)
})
(async () => {
const port = 8000
await app.start(port);
console.log(`⚡️ Slack Bolt app is running on port ${port}!`);
})()
I am new to slack API, and I am not able to understand how should I manipulate the request in order to see the commands in the channel as well
Any advice or help is appreciated!
Upvotes: 1
Views: 1650
Reputation: 374
Try adding it to your ack({"response_type": "in_channel"})
, that's what worked for me.
Upvotes: 3
Reputation: 257
You can use the respond
command in order to send a message that is visible within the channel:
await respond({"response_type": "in_channel", "text": "hello!"});
There's an example of this within the Bolt for JavaScript docs here: https://slack.dev/bolt-js/concepts#action-respond
Upvotes: 0