I'm working on building a slash command for slack in Javascript/Bolt( https://slack.dev/bolt/concepts)
It works "sometimes" but not always:
- [x] In a public channel
- [ ] In a private channel
- [ ] In a direct message
I'm using the bot token to authenticate but I'm pretty sure I'm running into some auth permission issues.
I'm trying to use the: chat.postEphemeral slack api to present an interactive display to my user.
In either the private or direct message situation my app is printing out a channel_not_found error which I assume is due to some permission error
[DEBUG] WebClient:0 apiCall('chat.postEphemeral') start
[DEBUG] WebClient:0 will perform http request
[DEBUG] WebClient:0 http response received
[DEBUG] bolt-app An API error occurred: channel_not_found
When things work correctly it looks like this:
[DEBUG] WebClient:0 apiCall('chat.postEphemeral') start
[DEBUG] WebClient:0 will perform http request
[DEBUG] WebClient:0 http response received
My slash command code looks like this - basically a simple reply with hi to the command:
app.command("/wl", async ({
command,
ack
}) => {
console.log(command)
await ack()
channel_id = command.channel_id
user_id = command.user_id
await app.client.chat.postEphemeral({
token: BOT_TOKEN,
channel: channel_id,
user: user_id,
text: "hi"
});
});
I've added every single option in the Bot Scope of the OAUTH page - and nothing seems to have done what I'm looking for.
1) Is it possible to actually write a valid slash command in bolt that works ever 2) Is it possible to do this with just using the BOT token or do I need to use the user token 3) What else am I missing?
Thanks