Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Injecting correct team_id into function context #65

Open
filmaj opened this issue Jun 7, 2024 · 4 comments
Open

Injecting correct team_id into function context #65

filmaj opened this issue Jun 7, 2024 · 4 comments

Comments

@filmaj
Copy link
Contributor

filmaj commented Jun 7, 2024

          Is there any timeframe on when they'll fix the api so it starts to either pass it, or at the very least so the CLI starts to set the correct team-id

My sandbox workspace config ends up like

{
  "E0776TLA88G": {
    "app_id": "xxx",
    "enterprise_id": "E0776TLA88G",
    "IsDev": true,
    "team_domain": "cm-xxxx",
    "team_id": "E0776TLA88G",
    "user_id": "U076F75ED6Z"
  }
}

But the app-install response correctly states

App successfully reinstalled
[2024-06-05 16:49:19] received: {"envelope_id":"2e43fb60-4cb0-4239-9365-1aa8f8034a03","payload":{"type":"block_actions","team":null,"enterprise":{"id":"E0776TLA88G","name":"cmbotsandbox"},"user":{"id":"U076F75ED6Z","name":"sd0776tdeq7j_user","team_id":"T076J49RGKC"}

The BaseRuntimeFunctionContext team_id is the same as the enterprise_id instead of being set to the team_id. Having to get around it using team_id: env["TEAM_ID"] || team_id || undefined,

Originally posted by @ChrisMcKee in slackapi/deno-slack-sdk#267 (comment)

@filmaj
Copy link
Contributor Author

filmaj commented Jun 7, 2024

@ChrisMcKee for your particular case, is the app installed to a specific team within the org, or to all teams within the org?

The details can be quite tricky here so this isn't just a matter of 'expose a missing property!' For example, in a channel shared across multiple workspaces (think Slack Connect), what should the team_id be set to?

The example payload you provide is a block_actions payload, and the team ID present in there is from the user that clicked the button. Users are associated to a 'home team' - you can feel free to use that property for the team, if you wish, but I'm not certain it would be broadly applicable as the generic team_id for the function handler to use.

@ChrisMcKee
Copy link

@filmaj When I deployed it via the CLI I chose team level. I usually use the slack-go library so what you say about the actions metadata being related to the user makes total sense (really miss step-by-step debugging in this). All of this is only an issue at an enterprise level. Luckily the place I work is on Business so it works fine as is for what I need at the moment.
It just made using the sandbox, which is enterprise by default, harder to use as the behaviour didn't seem consistent.

@jaywalker1981
Copy link

@filmaj Do you have an update on when this can be fixed? I need to utilize team_id as well.

I need to utilize team_id in my app so that I can invoke an API on my platform's backend. I am looking to map the team_id to my internal canonical org_id.
As this has been open for sometime, I am wondering if there is another way to pass the team_id to my backend?

@filmaj
Copy link
Contributor Author

filmaj commented Oct 30, 2024

@jaywalker1981 this issue is not so simple as it depends on the context of where your function is executed. The function_executed events are organization, not team-level, events when executing in an enterprise org. In such orgs, there could be multiple team IDs, so the question would be: which team ID should be provided as part of the payload? Depending on the context and your perspective, the answer may be different for you.

Can you share more information on the context for your function, and, if it is under your control, the workflow containing the function? There are ways to get relevant team ID context, such as calling the conversations.info API method, but there are many variables at play.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants