Comments (7)
@theshdb totally understand, and I mirror your sentiment and I have raised it internally. However, I am only one voice internally and many considerations go into what we do or do not do with the APIs. Priority and product decisions are made by leadership above my paygrade, unfortunately, however, leadership does pay attention to customer feedback that comes in via emails to [email protected]. Please consider emailing there and telling them you have a feature request / complaint about the deprecated API and what you'd like to see as a customer with regards to the new API.
As for retrieving the DM ID, you can use the conversations.open
API and provide the U....
encoded user ID as part of the users
argument. That should return a payload that looks like:
{
"ok": true,
"no_op": true,
"already_open": true,
"channel": {
"id": "D05TKNSGFL3"
}
}
from bolt-js.
Thanks for the clarification @filmaj. I'm aware of this functionality. However, my concern is that the deprecated method files.upload
allowed us to use Slack userId
to post a file in a direct message. So, why are we no longer supporting it in the new API? Can we not update the regex to include U
?
If no, then is it possible to retrieve a direct message ID using the Slack user ID via an API?
from bolt-js.
Got it @filmaj. Thanks for providing the solution on how to get the direct message ID.
This is what I'm using now as an alternate solution to post a file to a DM using a Slack user ID.
if (channelId.startsWith("U")) {
const conversationsResponse = await web.conversations.open({
users: channelId,
});
channelId = conversationsResponse.channel.id;
}
from bolt-js.
Great, glad you got it working. I will close this issue now but if there are any more questions here feel free to re-open or file a new issue.
from bolt-js.
Have you tried using the encoded D1234ABCD
direct message ID instead of the U1234ABCD
user ID to the channels list? As the error states, it does not allow passing user IDs into channel_id
; this parameter only accepts encoded IDs for public channels , group and direct msgs (IDs that start with C
, G
, D
and Z
).
In the Slack client, if you click on a direct message header's user name and scroll all the way down, you should be able to find the D...
encoded ID for a direct message that this API accepts:
![Screenshot 2024-05-15 at 9 21 51 AM](https://private-user-images.githubusercontent.com/52645/330820926-7842148b-c1ae-4701-b34c-ff1fe346637f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjEyNTA1MDMsIm5iZiI6MTcyMTI1MDIwMywicGF0aCI6Ii81MjY0NS8zMzA4MjA5MjYtNzg0MjE0OGItYzFhZS00NzAxLWIzNGMtZmYxZmUzNDY2MzdmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE3VDIxMDMyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVjODZjODQ1N2RjMzQyYTBiNDhkNzkyZGY1MGRjOGIwNDBmZDRmYjUzMzgyMWI4NDQ5ZDUyZjMzYTNiMzcyNWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.9hAOymufsFoAjnikKuzmhttFzTaNzSsSPYYFSLsKzcE)
from bolt-js.
@filmaj I got some problems I have upload the file to the server succeed,but I can not see the files in my channel. I have added the channel ID in my UploadPayload but it still didn't work
// Step 2: Upload file
using (var fileStream = new FileStream(screenshotPath, FileMode.Open, FileAccess.Read))
{
var fileContent = new StreamContent(fileStream);
fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
var uploadFileContent = new MultipartFormDataContent();
uploadFileContent.Add(fileContent, "file", fileName);
LogToFile($"上傳檔案的請求 URL: {uploadUrl}");
var uploadResponse = await client.PutAsync(uploadUrl, uploadFileContent);
var uploadResponseContent = await uploadResponse.Content.ReadAsStringAsync();
if (!uploadResponse.IsSuccessStatusCode)
{
return;
}
}
// Step 3: Complete Upload
var completeUploadPayload = new
{
files = new[]
{
new
{
id = fileId,
title = fileName
}
},
channel_id = "C076Q68GWTY"
};
var completeUploadPayloadJson = JsonConvert.SerializeObject(completeUploadPayload);
var completeUploadContent = new StringContent(completeUploadPayloadJson, Encoding.UTF8, "application/json");
var completeUploadResponse = await client.PostAsync("https://slack.com/api/files.completeUploadExternal", completeUploadContent);
var completeUploadResponseContent = await completeUploadResponse.Content.ReadAsStringAsync();
dynamic completeUploadResult = JsonConvert.DeserializeObject(completeUploadResponseContent);
if (completeUploadResult.ok == false)
{
return;
}
from bolt-js.
@william84531 The files should be shared in the channel members by the API call, but it's not visible because you haven't posted a message with them. You can add "initial_comment" parameter in addition to "channel_id" for posting a message with files.
If that's not the case, a different factor might be causing the issue. If so, I'd suggest trying any of the official Node/Python/Java SDKs first and then checking the difference in your C# code.
from bolt-js.
Related Issues (20)
- Select menu of external data source - Max number - Problem HOT 5
- The 'value' property on ButtonAction is incorrectly typed HOT 3
- Typing support for built-in middleware handlers
- Japanese document updates reflecting #2136
- Bug: Adding block elements through code make actions disable HOT 9
- How to handle errors with invalid signing secret? HOT 5
- link_shared does not seem to be automatically calling ack() HOT 10
- Event triggered by unknown workspace HOT 1
- Change dependencies -> peerDependencies HOT 1
- Getting We had some trouble connecting. Try again? after updating a view. Using aws lambda. HOT 3
- app.client.chat.postMessage not triggering message event HOT 2
- Cannot push modal view using `trigger_id` HOT 5
- Add invalidRequestSignatureHandler to HTTP/ExpressReceiver
- Intermittent UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'type' of undefined HOT 1
- How do you develop at 2 at the same time with Slack? HOT 1
- Incorrectly formatted threaded broadcast reply message will raise `thread_broadcast` event HOT 5
- `PinnedMessageItem` interface missing `ts` HOT 1
- Multiple fields missing in `ChannelCreatedEvent` interface
- (Set a clear title describing the issue) HOT 2
- `client.chat.postMessage` with a user token throws `invalid_auth` error HOT 1
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.