Comments (7)
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.
@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.
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.
@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.
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.
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.
👋 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)
- [ERROR] bolt-app no more than 100 items allowed [json-pointer:/view/blocks/0/element/options] HOT 13
- Unhandled request to /slack/install HOT 4
- Unhandled error log when user is not authorized HOT 8
- Cannot access the files in the "app_mention" event with TypeScript HOT 3
- How to get search params in custom routes HOT 4
- appToken is not read in socketMode @3.18.0 HOT 4
- Links with ampersand do not work in Slack iOS app HOT 6
- Add flag to `AwsLambdaReceiver` to disable Signature Verification HOT 1
- Events Subscription is continuously being turned off when we kill the process HOT 4
- Add reply_in_thread method HOT 1
- Run multiple replicas in k8s of bot app HOT 2
- Frequent disconnects in socket mode HOT 9
- Unable to upload a file in a direct message using files.completeUploadExternal HOT 7
- `too_many_websockets` causes Cannot read properties of undefined (reading 'event') HOT 5
- Cannot respond to incoming message events with `say` using the Bun runtime HOT 5
- Keep getting Error: Cannot write headers after they are sent to the client HOT 3
- How do I create a custom ConsoleLogger? HOT 1
- Better typing for block actions payload HOT 3
- How to access Company ID during OAuth for Slack App Installation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bolt-js.