How to Convert Slack User ID into Actual Text in a Slack Message Action Step?

This topic was automatically generated from Slack. You can find the original thread here.

How do I convert the Slack User ID into its actual text counterpart into a Slack send message action step?

To convert a Slack User ID into its actual text counterpart in a Slack send message action step, you can use the Slack API to retrieve the user’s profile information, which includes their display name. Here’s a step-by-step guide on how to achieve this using Pipedream: 1. Search for the Slack app in the Pipedream UI: Start by adding a new step in your workflow and search for the Slack app. 2. Use the Slack API to get user info: Before sending a message, you can use the Slack API to get user information. You can do this by making a request to the [users.info](http://users.info) endpoint, which returns details about a user, including their display name. 3. Send a message with the user’s display name: Once you have the user’s display name, you can include it in the message text in your Slack action step. Here’s an example of how you might implement this in a Pipedream component: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { slack: { type: "app", app: "slack", }, userId: { type: "string", label: "Slack User ID", }, channelId: { type: "string", label: "Channel ID", }, }, async run({ steps, $ }) { // Fetch user info const userInfo = await axios($, { url: `https://slack.com/api/users.info`, headers: { Authorization: `Bearer ${this.slack.$auth.oauth_access_token}`, }, params: { user: this.userId, }, }); const displayName = userInfo.user.profile.display_name || userInfo.user.name; // Send message to Slack await axios($, { url: `https://slack.com/api/chat.postMessage`, method: "POST", headers: { Authorization: `Bearer ${this.slack.$auth.oauth_access_token}`, "Content-Type": "application/json", }, data: { channel: this.channelId, text: `Hello, ${displayName}!`, }, }); }, }); ### Explanation: - Slack API Request: The [users.info](http://users.info) endpoint is used to fetch user details using the Slack User ID. - Display Name: The user’s display name is extracted from the response. If the display name is not set, it defaults to the username. - Send Message: The chat.postMessage endpoint is used to send a message to a specified channel, including the user’s display name in the message text. This approach allows you to dynamically convert a Slack User ID into a human-readable name and include it in your messages.

Are you trying to @mention someone?

Hi , not really. I’m trying to put the actual user name from slack into a notion page.

Oh cool then #2 from Pi’s response is what you want

Its the HTTP request Slack action right? I tried doing it, but I’m not getting the right value from the User ID from the trigger step. Its returning my Slack user data, instead of the person who send the message.

Check out Slack’s docs here: