slackapi / bolt-python

A framework to build Slack apps using Python

Home Page:https://slack.dev/bolt-python/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting icon_url in chat_postMessage works for some and not for others

rsoome opened this issue Β· comments

Reproducible in:

The slack_bolt version

1.18.1

Python runtime version

Python 3.11.1

OS info

Alpine Linux 3.19.1

Steps to reproduce:

(Share the commands to run, source code, and project settings (e.g., setup.py))

  1. Get all users that are in a Slack channel:
def fetch_slack_users(app):
  logging.info("Fetching users from Slack")

  # Get all Slack users
  users_list = app.client.users_list()
  if users_list["ok"] != True:
      raise LookupError("Unable to fetch user list. Exiting.")

  logging.info("Slack users fetched")
  return users_list["members"]
  
app = App(token=os.environ.get("SLACK_BOT_TOKEN"))
slack_users = fetch_slack_users(app)

2.Acquire some user that's in a Slack channel
i.e

def look_up_slack_user_by_id(uid):
  logging.info("Looking up Slack user by ID %s", uid)
  for user in slack_users:
    if uid == user["id"]:
      return user

  raise SlackUserLookupError(name=event["user"] + ".", comment="This should never happen") # A custom exception

user = look_up_slack_user_by_id(SOME_EXISTING_USER_ID)
  1. Try to post a reply to some thread using the name and icon of the user:
text_to_channel = "Some text."
reply_text = "Replying as some user: %s"%(SOME_EXISTING_USER_ID)

username = event_user["profile"]["display_name"] if event_user["profile"]["display_name"] else event_user["profile"]["real_name"]

post = app.client.chat_postMessage(channel=SOME_EXISTING_CHANNEL_ID, text=text_to_channel, mrkdwn=True)
reply = app.client.chat_postMessage(token=os.environ.get("SLACK_BOT_TOKEN"), channel=SOME_EXISTING_CHANNEL_ID,
                                                           text=reply_text, icon_url=user["profile"]["image_48"], mrkdwn=True,
                                                           thread_ts=post["ts"], username=username)

Expected result:

The reply posted to the thread is posted with the name of 'user' as well as the icon of 'user' and this can be constantly observed in different clients.

Actual result:

Although the name is correct, the icon is set correctly for some reading the thread while is not set correctly for others reading the thread (the icon of the bot itself is seen in these cases).

The following are 2 screenshots, one taken in Arch linux and using Slack web client (Ferdium v6.5.1 using Chromium) and the other screenshot is of the same thread logged in to Slack as the same user but using iPhone Slack app.

image

Hi, @rsoome! Thanks for submitting your question! πŸ™Œ

Based on the examples you provided, this looks like a parity issue between web vs. mobile client - is that correct? Have you been able to see what the desired output for the messages for the desktop client as well?

Hi, thank you for your quick reply!

This issue, at first glance at least, does not seem to have any real pattern. What I've seen thus far:

  • TWO cases of Android Slack apps BEING ABLE to display the icons
  • TWO cases of Slack web client BEING ABLE to display the icons (Using Ferdium)
  • ONE case of Slack web client BEING ABLE to display the icons (Using Rambox)
  • THREE cases of the iPhone Slack apps NOT being able to display the icons
  • ONE case of Slack web client NOT being able to display the icons (Using Rambox)

Right now I haven't been able to find anyone in the office who is using desktop client. Will try my luck again tomorrow.

@rsoome Thank you so much, please keep me updated! Yeah, as of right now it seems like there's no clear pattern 😒 In the meantime I'll do some digging on my end through old issues as well to see if I can find some history on this issue or a potential workaround, will drop back in with updates!

If anyone else is facing this issue, I encourage them to post a comment here so we can track it better and see if there's any consistencies πŸ˜„

Hi again, @hello-ashleyintech

I got ahold of 3 people who are using the Slack Desktop Client. For all of them, the icons display correctly. (2 people using version 4.36.138 and 1 using 4.36.140).

Ah, interesting @rsoome! This does sound like it could be an issue based on what client you're using - sounds like it might be working and configured perfectly for desktop but is flaky on other clients.

I will mark this as a server side issue and reach out to the appropriate team internally to get additional insight into whether this is a known issue or not! Thank you for submitting this. I'll drop in any updates I receive! πŸ™Œ

πŸ‘‹ It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.