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

bolt-js's ack(string) does not work in Socket Mode #1455

Closed
1 of 6 tasks
seratch opened this issue Mar 30, 2022 · 0 comments · Fixed by #1456
Closed
1 of 6 tasks

bolt-js's ack(string) does not work in Socket Mode #1455

seratch opened this issue Mar 30, 2022 · 0 comments · Fixed by #1456
Assignees
Labels
bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented pkg:socket-mode applies to `@slack/socket-mode`

Comments

@seratch
Copy link
Member

seratch commented Mar 30, 2022

The ack function that @slack/socket-mode offers does not accept a string value in the way the ack() in HTTP endpoint based bolt-js receivers do. Specifically, the following slash command handler does acknowledge a request but it does not post the "Hi there" mesage in the Slack channel.

const { App } = require("@slack/bolt");
const app = new App({
  socketMode: true,
  appToken: process.env.SLACK_APP_TOKEN,
  token: process.env.SLACK_BOT_TOKEN,
});

app.command("/hello", async ({ ack }) => {
  await ack("Hi there!");
});

(async () => {
  await app.start();
  console.log("⚡️ Bolt app is running!");
})();

The cause is the way that the send method handles the body parameter:

$ node
Welcome to Node.js v16.13.2.
Type ".help" for more information.
> const body = "Hi there!"
undefined
> const payload = { ...body };
undefined
> payload
{
  '0': 'H',
  '1': 'i',
  '2': ' ',
  '3': 't',
  '4': 'h',
  '5': 'e',
  '6': 'r',
  '7': 'e',
  '8': '!'
}
>

see: https://github.com/slackapi/node-slack-sdk/blob/%40slack/socket-mode%401.2.0/packages/socket-mode/src/SocketModeClient.ts#L424-L425

Packages:

Select all that apply:

  • @slack/web-api
  • @slack/rtm-api
  • @slack/webhooks
  • @slack/oauth
  • @slack/socket-mode
  • I don't know

Steps to reproduce:

See the above JS script.

Expected result:

The app's bot user post a new message "Hi there!"

Actual result:

No message is posted.

@seratch seratch added bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented pkg:socket-mode applies to `@slack/socket-mode` labels Mar 30, 2022
@seratch seratch added this to the socket-mode@1.3.0 milestone Mar 30, 2022
@seratch seratch self-assigned this Mar 30, 2022
seratch added a commit to seratch/node-slack-sdk that referenced this issue Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented pkg:socket-mode applies to `@slack/socket-mode`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant