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

Slack integration with Obot #1991

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

StrongMonkey
Copy link
Contributor

@StrongMonkey StrongMonkey commented Mar 7, 2025

This is the exact workflow/UX user will have to follow if they want to configure a custom app in their workspace and being able to delegate task to the task from every message that mentions the bot:

  1. Use /api/assistants/{assistant_id}/projects/{project_id}/slack/configure to configure a custom oauth app for their obot and get a id. They need to create a slack app, configure the callback url to /api/slack/oauth/callback/{id}, set event redirect url to /api/slack/event and all the right scopes.

  2. Use /api/assistants/{assistant_id}/projects/{project_id}/slack/authorize to authorize. This will bind Obot with the workspace they have signed in. We will save the team id and name into the obot so that UI can create slack trigger based on the information. Slack trigger is a 1 to 1 mapping bewteen (workspace_id and app_id) to task.

  3. Use /api/slack-triggers to create trigger to trigger task from your slack workspace.

The UX on the end user would be:

  1. User develops their own slack app and configure that on the Obot level.
  2. User autheticate slack with their app and install to their workspace.
  3. User is able to trigger tasks by mention their own app in their workspace.
  4. User will be able to do oauth with their own app using our slack/slack-bot tool.

image

@StrongMonkey StrongMonkey changed the title wip Slack integration with Obot Mar 10, 2025
@StrongMonkey StrongMonkey force-pushed the slack-poc branch 2 times, most recently from 7ec16f7 to 7cf2086 Compare March 10, 2025 07:30
Copy link
Contributor

@cjellick cjellick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more comments to come, just wanted to get these ones out there

@@ -673,6 +673,22 @@ func (h *ProjectsHandler) authenticate(req api.Context, local bool) (err error)
return err
}

var oauthApps v1.OAuthAppList
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this block of code do?

@@ -8,7 +8,8 @@ export default defineConfig({
'/api': 'http://localhost:8080',
'/admin': 'http://localhost:8080',
'/oauth2': 'http://localhost:8080'
}
},
allowedHosts: ['04ac-70-184-112-91.ngrok-free.app']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i assume this is a short term thing?

@@ -247,7 +247,7 @@ func OAuthAppEnv(ctx context.Context, db kclient.Client, oauthAppNames []string,

for _, integration := range slices.Sorted(maps.Keys(activeIntegrations)) {
app := activeIntegrations[integration]
integrationEnv := strings.ReplaceAll(strings.ToUpper(app.Spec.Manifest.Alias), "-", "_")
integrationEnv := strings.ReplaceAll(strings.ToUpper(string(app.Spec.Manifest.Type)), "-", "_")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change?

return err
}

scopes := []string{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we let the obot author define scopes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be removed. We don't really need scopes here, just need to have user go to the oauth flow and install the app to their workspace.

return &SlackEventHandler{invoker: invoker, gptscript: gptscript}
}

type SlackEvent struct {
Copy link
Contributor

@cjellick cjellick Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in their docs, they make a big deal about verify thing token

https://api.slack.com/apis/events-api

The shared-private callback token that authenticates this callback to the application as having come from Slack. Match this against what you were given when the subscription was created. If it does not match, do not process the event and discard it. Example: JhjZd2rVax7ZwH7jRYyWjbDl

Should we be checking that as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is deprecated. Using the sign secret is in favor of.

This deprecated Verification Token can still be used to verify that requests come from Slack, but we strongly recommend using the above, more secure, signing secret instead.

@@ -123,6 +124,14 @@ func Router(services *services.Services) (http.Handler, error) {
mux.HandleFunc("GET /api/assistants/{assistant_id}/projects/{project_id}/env", assistants.GetEnv)
mux.HandleFunc("PUT /api/assistants/{assistant_id}/projects/{project_id}/env", assistants.SetEnv)

// Project Slack integration
mux.HandleFunc("GET /api/assistants/{assistant_id}/projects/{project_id}/slack/authorize", projects.SlackAuthorize)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does this get used? do i drop it into slack somewher?

app.Spec.Manifest.ClientID,
url.QueryEscape(strings.Join(scopes, ",")),
url.QueryEscape(strings.Join(userScopes, ",")),
url.QueryEscape(fmt.Sprintf("https://%s/api/slack/oauth/callback/%s", req.Host, app.Name)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to use something other than req.host.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theres an env var

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

Successfully merging this pull request may close these issues.

2 participants