Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
slack get message sender name for messages return from conversation.history api

I am calling slack API(conversations.history) to get channel messages. I want to retrieve sender name in message response. how can i get it?

below is my message response:

{  "client_msg_id": "0e19ca7d-1072-4f73-a932-9ec7fa9956de",
          "type": "message",
          "text": "Yeah good edge case, I would agree, just mentioning \" no data found\"",
          "user": "U01JW9D10PQ",
          "ts": "1642216920.001100",
          "team": "T01K38V9Q7M", blocks:[]}
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can use the user id returned from the user key to make a call to users.info after you receive that payload.

over 4 years ago · Santiago Trujillo Report

0

The conversations.history API doesn't return user information (just user id), you may need to fetch each user from the channel history, see an example code:

Get Slack channel history users                                                                                 Run in Fusebit
const channelId = 'C02TSNCQ2Q2';
const channelHistory = await client.conversations.history({
  channel: channelId,
});

// Get the user ids from the history and populate an array with the user details
const userList = [];
for await (let message of channelHistory.messages) {
  const userAdded = userList.find(user => user.id === message.user);
  if (!userAdded) {
    const response = await slackClient.users.info({
      user: message.user,
    });

    if (response.ok) {
      const { id, name, real_name, profile, is_bot } = response.user;
      userList.push({ id, name, real_name, profile, is_bot });
    }
  }
}

console.log(`There are ${userList.length} users in the channel conversation:\n${userList.map(user => `${(user.is_bot ? '🤖' : '👤')} ${user.name}`).join('\n')}`);

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!