Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slash command endpoint #209

Closed
4 of 9 tasks
evanhli opened this issue Jun 24, 2019 · 10 comments
Closed
4 of 9 tasks

Slash command endpoint #209

evanhli opened this issue Jun 24, 2019 · 10 comments

Comments

@evanhli
Copy link

evanhli commented Jun 24, 2019

Description

Hi, i've been trying to setup slash commands for a bot but can't seem to find the endpoint that the slash command is listening at.

I've copied the below from the example given by the docs:

app.command('/echo', async ({ command, ack, say }) => {
  // Acknowledge command request
  ack();
  say(`${command.text}`);
});

In my slack app slash command config, I've created a new command at
https://localtunnel/echo
https://localtunnel/slack/command
https://localtunnel/slack/command/echo
https://localtunnel/slack/commands/echo

But I always get an error: Darn - that slash command didn't work (error message: '404_client_error'). Manage the command at Test App.

Am I pointing at the wrong endpoint or is there something else going wrong?

Thanks

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.
@shaydewael
Copy link
Contributor

@evanhli All of the endpoints are configured to be the same for simplicity: /slack/events (so in your case https://localtunnel/slack/events).

If you'd like, you can optionally pass in your own endpoint(s) to the constructor using the endpoints argument:

const app = new App({
  signingSecret: process.env.SLACK_SIGNING_SECRET,
  token: process.env.SLACK_BOT_TOKEN,
  endpoints: {
     events: '/slack/events',
     commands: '/slack/commands' 
   }
});

@evanhli
Copy link
Author

evanhli commented Jun 25, 2019

Thanks!

@evanhli evanhli closed this as completed Jun 25, 2019
@TK95
Copy link
Contributor

TK95 commented Jul 27, 2019

@evanhli All of the endpoints are configured to be the same for simplicity: /slack/events (so in your case https://localtunnel/slack/events).

If you'd like, you can optionally pass in your own endpoint(s) to the constructor using the endpoints argument:

const app = new App({
  signingSecret: process.env.SLACK_SIGNING_SECRET,
  token: process.env.SLACK_BOT_TOKEN,
  endpoints: {
     events: '/slack/events',
     commands: '/slack/commands' 
   }
});

This should be mentioned in the guide.

I've faced the same issue as well.

@jemmy512
Copy link

This is really should be mentioned in the guide. I met the same problem.

@evanhli All of the endpoints are configured to be the same for simplicity: /slack/events (so in your case https://localtunnel/slack/events).
If you'd like, you can optionally pass in your own endpoint(s) to the constructor using the endpoints argument:

const app = new App({
  signingSecret: process.env.SLACK_SIGNING_SECRET,
  token: process.env.SLACK_BOT_TOKEN,
  endpoints: {
     events: '/slack/events',
     commands: '/slack/commands' 
   }
});

This should be mentioned in the guide.

I've faced the same issue as well.

@evanhli All of the endpoints are configured to be the same for simplicity: /slack/events (so in your case https://localtunnel/slack/events).

If you'd like, you can optionally pass in your own endpoint(s) to the constructor using the endpoints argument:

const app = new App({
  signingSecret: process.env.SLACK_SIGNING_SECRET,
  token: process.env.SLACK_BOT_TOKEN,
  endpoints: {
     events: '/slack/events',
     commands: '/slack/commands' 
   }
});

This is really really should be mentioned in the guide.
I met the same problem.

@simonkubica
Copy link

+1 to others, please update the guide. For those encountering the same issue: Your code is likely correct - you need to update the Request URL of your slash command in app management to point to /slack/events

@dschinkel
Copy link

dschinkel commented Jul 10, 2020

So..yes the docs now talk about this but it was extremely misleading still easy to gloss over, and confusing still coming from originally coding against the Slack API and not Bolt. I spent an hour trying to figure out and finally realizing this after coming across this issue which helped.

I was coding against /slack/actions and kept hitting my head against the wall as to why my app.action was not being hit. It was because Bolt was expecting /events which is just weird to me TBH. It's a convenience for you that makes it hella confusing for us Slack Team!

I suggest either:

1) Put an additional note to that effect in the beginning of the Actions section of the doc
2) better would probably be to just keep consistent with how the Slack API works for this and just tell people to use the endpoints prop in the app configuration to make it consistent with how the Real Slack API works. That way, there is no chance of people missing that part in your docs. I realize that for you it's "nice" but really it's not great for devs using Bolt because we're looking and using the Slack API configuration in the end

It's better to be explicit here. Stop the subtle difference between how Bolt treats the urls vs core Slack API patterns. There are some things you need to maintain consistency on and I think the core url pattern that you see most people setup in their API should be consistent with what we're putting in our incoming hooks value vs. events which are really two separate domain concepts.

@dginovker
Copy link

dginovker commented Jul 21, 2020

From the top, here's what worked for me:

In the Slack Slash Commands page, set the request URL to ip:port/slack/events:

image

Initialize your Bolt app as you would normally:

export const app = new bolt.App({
  token: process.env.SLACK_BOT_TOKEN,
  signingSecret: process.env.SLACK_SIGNING_SECRET
});
app.command('/burn', async (everything: any) => {    //Ignore the :any if you're not using Typescript
  everything.ack();

  console.log(JSON.stringify(everything));    //A good way to see what variables you have to play with
});

And then for simplicity, I use the app.client.chat.postMessage to craft my response. You can get the channel and everything else within the everything variable above.

Hopefully this helps someone 🚀

@nurgasemetey
Copy link

@dginovker 's message should be on guide because many new developers will certainly struggle and it is not good for Slack

@zombieleet
Copy link

@nurgasemetey for some reason the endpoints options accepts only this values string | string[] | undefined , so I don't think the answer is valid anymore 😞 .

cc: @dginovker

@MelonCode
Copy link

This is still a thing in 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants