0

I have a Slack App that is connected to an AWS Lex bot. Thus, the Request URL for the Slack app is the Postback URL provided by Lex. However, I want to add a Home tab for the app, but am unable to publish a surface for all users. The Slack API only seems to allow you to publish a surface for a specific user (user_id is a required parameter for the POST call). How can I publish this view to all users who use the app?

publish_url = "https://slack.com/api/views.publish"
header = {'content-type':'application/json'}
parameters = {
    "token": slack_token,
    "user_id": member_id,      # <--- This is my problem
    "view": json.dumps({
        "type": "home",
        "blocks": [
            {
                "type": "section",
                "text": {
                    "type": "mrkdwn",
                    "text": "Welcome to *Survey Analyzer*! ..."
                }
            },
            ...
          ]
        })
    }
r = requests.post(publish_url, params=parameters, headers=header)

When I use my own member ID, it pushes the view properly to me and me only. I've also tried using the app's ID, but that doesn't seem to push the view to any users.

Desi Pilla
  • 544
  • 6
  • 20

1 Answers1

0

You can only publish a home tab for each user separately. You can use users.list to retrieve all users of a workspace and then call views.publish for each user in that list.

Alternatively you can subscribe to the app_home_opened event through the Events API. Once a user opens the home tab it will fire an event including the user's id. That way you'll only publish a view for a user who is actually visiting the home tab of your app.

pichsenmeister
  • 2,132
  • 4
  • 18
  • 34