Code Monkey home page Code Monkey logo

Comments (7)

seratch avatar seratch commented on July 18, 2024

Hi @jpventura, thanks for asking the question! What "chat:write.customize" scope gives to your app might be confusing, but as mentioned at slackapi/bolt-python#611, this bot scope allows your app to send a "bot" message with a personalized icon and username. This feature is supposed to be used for visualizing bot and various user interactions within a Slack thread conversation.

For your use case, your app needs to serve the OAuth flow for app installation and ask each your end user to grant your app to post a message on behalf of them. More specifically, chat:write in user_scope in the OAuth flow is necessary. Behaving as a human user is so critical that your app needs to receive approval from each user to do so.

I hope this helps.

from bolt-js.

jpventura avatar jpventura commented on July 18, 2024

@seratch I tried exactly this call and the icon and name change does not happen. The permission was added to the bot, but it does not seems to work on new apps.

from bolt-js.

seratch avatar seratch commented on July 18, 2024

Just in case, I verified there is no such issue with a newly created app. I create a new app and confirmed the app works for me without any issues. To narrow your issue down, I'd suggest making sure the following:

  • Your app needs to have not only chat:write but also chat:write.customize scope
  • If you add chat:write.customize after the app installation, you need to re-install the app to grant the addiional scope
  • If you're using a user token (xoxp- prefix), it's not possible to customize name and icon for it

I hope this helps.

from bolt-js.

jpventura avatar jpventura commented on July 18, 2024

@seratch Thank you for your attention.

We discovered the problem. According to the documentation, as_user parameter is required only for legacy apps. Including it into new apps causes the unexpected behavior.

The following code works as expected:

const result = await app.client.chat.postMessage({
      channel: channel_id,
      icon_url: 'https://i.pinimg.com/736x/b5/13/5f/b5135f5280b8ccb7b48c0bb9eaedc158.jpg',
      text: 'All your bases are belong to us', 
      token: process.env.SLACK_BOT_TOKEN,
      username: 'CATS',
});

However it does not seem to work with app.client.files.upload function. Is it an API restriction or should it work as well?

from bolt-js.

jpventura avatar jpventura commented on July 18, 2024

I just checked the code and compared the app.client.files.upload arguments:

export interface FilesUploadArguments extends FileUpload, WebAPICallOptions, TokenOverridable {
}

interface FileUpload {
    channels?: string;
    content?: string;
    file?: Buffer | Stream | string;
    filename?: string;
    filetype?: string;
    initial_comment?: string;
    thread_ts?: string;
    title?: string;
}

and app.client.chat.postMessage

export interface ChatPostMessageArguments extends WebAPICallOptions, TokenOverridable {
      channel: string;
      text?: string;
      as_user?: boolean;
      attachments?: MessageAttachment[];
      blocks?: (KnownBlock | Block)[];
      icon_emoji?: string;
      icon_url?: string;
      metadata?: MessageMetadata;
      link_names?: boolean;
      mrkdwn?: boolean;
      parse?: 'full' | 'none';
      reply_broadcast?: boolean;
      thread_ts?: string;
      unfurl_links?: boolean;
      unfurl_media?: boolean;
      username?: string;
}

So I would guess that this feature is unsupported and it would require a patch into the library.

from bolt-js.

seratch avatar seratch commented on July 18, 2024

Hi @jpventura, I overlooked you were trying to use as_user option, but you're right that the option should not be used along with username and icon for the latest permission. As for files.upload API, it does not support the parameters. However, you can do the following instead:

  • Upload files using files.uploadV2 without channel_id and initial_comment parameters (at this point, the files are uploaded but not yet shared)
  • Post a message with uploaded file permalink URLs in a channel along with username and icon using chat.postMessage API

I hope this helps.

from bolt-js.

github-actions avatar github-actions commented on July 18, 2024

👋 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.

from bolt-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.