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

reply_broadcast does not send as user even if as_user is enabled #1845

Open
1 of 7 tasks
asportnoy opened this issue Jul 12, 2024 · 8 comments
Open
1 of 7 tasks

reply_broadcast does not send as user even if as_user is enabled #1845

asportnoy opened this issue Jul 12, 2024 · 8 comments
Labels
backend Issue related to the Slack API bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented

Comments

@asportnoy
Copy link

asportnoy commented Jul 12, 2024

(Filling out the following with as much detail as you can provide will help us solve your issue sooner.)

Packages:

Select all that apply:

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

Reproducible in:

The Slack SDK version

v7.3.1

Node.js runtime version

v20.12.2

OS info

ProductName:            macOS
ProductVersion:         14.5
BuildVersion:           23F79
Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000

Steps to reproduce:

// Using the "User OAuth Token" from the "OAuth & Permissions" tab
export const slack = new WebClient('TOKEN');
const channel = 'YOUR CHANNEL ID HERE';

const message = await slack.chat.postMessage({
    channel,
    as_user: true,
    text: 'testing',
});

await slack.chat.postMessage({
    channel,
    thread_ts: message.ts!,
    as_user: true,
    text: 'testing',
});

await slack.chat.postMessage({
    channel,
    thread_ts: message.ts!,
    as_user: true,
    text: 'testing two',
    reply_broadcast: true,
});

Expected result:

All 3 messages should send using my profile since as_user is enabled

Actual result:

The first two messages sent as my profile, but the one with reply_broadcast enabled sent as the app and not my profile.

Screenshot 2024-07-12 at 11 15 20

I also tried to send a message and then update it as a workaround, but it turned into the application as soon as I tried to update it.

const message = await slack.chat.postMessage({
    channel,
    as_user: true,
    text: 'testing',
});
const threadMsg = await slack.chat.postMessage({
    channel,
    thread_ts: message.ts!,
    as_user: true,
    text: 'testing',
});
await slack.chat.update({
    ts: threadMsg.ts!,
    channel,
    reply_broadcast: true,
});

PS: TypeScript considers that last one to be an invalid type even though it doesn't seem to be invalid. Might want to fix that.

Requirements

For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. 🙇

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

@WilliamBergamin WilliamBergamin added question M-T: User needs support to use the project and removed untriaged labels Jul 15, 2024
@WilliamBergamin
Copy link
Contributor

Hi @asportnoy thanks for writing in 💯

Have you tried setting as_user=True for the chat.update request?

It should be something like this

await slack.chat.update({
    channel,
    ts: threadMsg.ts!,
    as_user: true,
    reply_broadcast: true,
});

@asportnoy
Copy link
Author

Thanks for the suggestion @WilliamBergamin, unfortunately no dice there. Still turns into the app user when updating.

@ArcticSnowman
Copy link

I suspect this is a bug in the slack API as it happens with the GO SDK as well.

@WilliamBergamin
Copy link
Contributor

Yes from my testing this appear to be a bug with the slack API

The following also leads to this strange behavior

    const message = await client.chat.postMessage({ channel: "C123", as_user: true, text: "testing" })
    const threadMsg = await client.chat.postMessage({
      channel: "C123",
      thread_ts: message.ts,
      as_user: true,
      text: 'testing',
      reply_broadcast: true
    });

I'll raise this internally but anyone encountering this issue can report it through /feedback command or [email protected]

@WilliamBergamin WilliamBergamin added bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented backend Issue related to the Slack API and removed question M-T: User needs support to use the project labels Jul 15, 2024
@ArcticSnowman
Copy link

If I were to guess it's probably the API code that takes the message and clone/updates it to post in two places with those nice links. Probably not passing the as_user to the update API call. This is suggested to me as my BOT is showing messasge_update events being sent out

Copy link

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

@asportnoy
Copy link
Author

unstale please

@seratch
Copy link
Member

seratch commented Aug 19, 2024

(I do understand this could be confusing but) the as_user parameter is a legacy parameter, which works only for classic Slack apps.

(Legacy) Pass true to post the message as the authed user instead of as a bot. Defaults to false. Can only be used by classic Slack apps. See authorship below.
https://api.slack.com/methods/chat.postMessage#arg_as_user

The classic apps are no longer available for newly created apps for a while. Thus, you cannot use this parameter anymore. This document page https://api.slack.com/methods/chat.postMessage#arg_as_user should emphasize this much more, so I will ask the document team to update it.

If you want to customize the icon and user name, you can use chat:write.customize scope. With this permission, your chat.postMessage API call can include icon_url etc. With that being said, when you post a message using chat:write.customize, the message is still by your app's bot user, not a human. Please refer to slackapi/bolt-python#611 (comment) too.

I hear this could be inconvenient and confusing, but my answer here clarifies things for you all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Issue related to the Slack API bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented
Projects
None yet
Development

No branches or pull requests

4 participants