-1

I have been following the documentation to select a user from my workspace using the Slack app API kit.

However, once I select a user this is the payload that is show in the action listener

{
  type: 'users_select',
  action_id: 'user_select',
  block_id: 'section678',
  selected_user: 'U02GL7WT4JX',
  action_ts: '1633620609.616449'
}

Technically, I do have the user via the ID, but I was hoping that I would be able to get the slack display name rather than the id. I've been looking at the slack documentation but I see no other way to get the username other than using the Slack REST API.

I would rather get the slack display name from using the App kit rather than the slack rest api. Is this possible?

pythonNovice
  • 1,130
  • 1
  • 14
  • 36
  • The idea of a "username" was [phased out by Slack in September 2017](https://api.slack.com/changelog/2017-09-the-one-about-usernames), opting instead for the use of a "display name" which allows for more flexibility for end users. – esqew Oct 07 '21 at 15:41
  • 1
    I think you need to use the Rest API, or not display the name. – ᴓᴓᴓ Oct 07 '21 at 15:47

1 Answers1

2

I overestimated the difficulty of this task. Turns out bolt allows for easy access to the web api as stated here

Here's my resulting code

index.js

  const result = await client.users.info({
     user: payload.selected_user,
  });
  this.selectedUser = result.user.name;
pythonNovice
  • 1,130
  • 1
  • 14
  • 36