slackapi / java-slack-sdk

Slack Developer Kit (including Bolt for Java) for any JVM language
https://slack.dev/java-slack-sdk/
MIT License
570 stars 209 forks source link

Field mismatch with to response. #1267

Closed abubakar364 closed 7 months ago

abubakar364 commented 7 months ago

In slack user model we have variable private String teamId;

However the API response from slack is team_id. So when we call the API in JAVA is says no variable found against team_id; How can I handle that ?

seratch commented 7 months ago

Hi @abubakar364, thanks for asking the question. This SDK maps the snake_cased field names to camelCased names to follow the common standard in Java programming. So, all you need to do is just to use getTeamId() of an object.

abubakar364 commented 7 months ago

Hi @seratch Thank you so much for the clarification. One more question is there a way we can fetch the channel Id using receiver Id ?

seratch commented 7 months ago

What do you mean by the "receiver" id? If that's a user ID in an event payload and you'd like to know the channel ID for the DM with the person, you can perform conversations.open API call to create a new one or get the ID if it already exists. If you meant a different scenario, could you elaborate on that more?

abubakar364 commented 7 months ago

Yeah, So what my use case is I'm designing a chat app using Slack. I have shown the list of users. I can send messages using userID in the payload. However, when I have to fetch the history of that channel I don't have the channel ID. So is there a way I can get a channel ID for the DM ? or any better approach for my use case.

seratch commented 7 months ago

Okay, so as I mentioned above, you can call conversations.open API to know the DM channel ID. For 1:1 DM with your app's bot user, you can pass a single user ID as the "users" parameter: https://api.slack.com/methods/conversations.open

If everything is clear now, would you mind closing this issue?

abubakar364 commented 7 months ago

Yup sure Thanks