1

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!

Dummy Cron
  • 143
  • 2
  • 11

2 Answers2

1

Try adding it to your ack({"response_type": "in_channel"}), that's what worked for me.

cciollaro
  • 354
  • 4
  • 10
0

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

Jason
  • 121
  • 1
  • 1
    This doesn't work. Here are the replies with hello, I am not able to see when the user sends the command. As soon as the user sends the command the bot says hello! If you look at this https://api.slack.com/interactivity/slash-commands#responding_response_url here as the user sends /weather it is visible in the channel, I want to achieve that. – Dummy Cron Sep 06 '22 at 07:50