slackapi / bolt-python

A framework to build Slack apps using Python
https://tools.slack.dev/bolt-python/
MIT License
1.07k stars 246 forks source link

How to know team_id in app_home_opened event listeners #520

Closed Cyb-Nikh closed 3 years ago

Cyb-Nikh commented 3 years ago

Unable to see view in app_home_opened event:

@bolt_app.event("app_home_opened")
def handle_home_tab(client, event, logger):
    print('Event: ', event)
    # get event['view']
Event: {'type': 'app_home_opened', 'user': 'U0*********', 'channel': 'D0*********', 'tab': 'home', 'event_ts': '163*****.*******'},

No view is there, what I read is for first time when this event occur since no view was there we didn't get view field but I need team_id to identify that workspace in my backend. Is there any way I can fetch team_id before I publish my home view for the first time

seratch commented 3 years ago

Hi @Cyb-Nikh, thanks for writing in! You can use context.team_id for it.

Cyb-Nikh commented 3 years ago

Hi @seratch Thank you for the response.

context.team_id is what I was needed. Thanks for the help.

I'm closing it as the issue has been resolved.