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

Overriding callbackOptions while keeping default behavior #1766

Open
gilmatok opened this issue Mar 16, 2023 · 2 comments
Open

Overriding callbackOptions while keeping default behavior #1766

gilmatok opened this issue Mar 16, 2023 · 2 comments
Labels
auto-triage-skip Prevent this issue from being closed due to lack of activity enhancement M-T: A feature request for new functionality
Milestone

Comments

@gilmatok
Copy link
Contributor

gilmatok commented Mar 16, 2023

You can override the callbackOptions and provide additional logic to run before/after installing the Slack app.

We use it to send a welcome message to the installing user after a succesfull installation. However, you need to manually end the response using res.end:

callbackOptions: {
        success: (installation, _options, _req, res) => {
          app.client.chat.postMessage({
            token: installation.bot.token,
            channel: installation.user.id,
            text: 'Welcome to my app!'
          });

          res.end('Success!');
        }
      }

This example just displays a basic message, rather than the default Slack page that displays when no logic is provided, that also automatically redirects to the Slack app, along with a magic link:

image

Requirements

I want the callback to provide a default, that you can call after executing your custom logic, which will show the same page but will still allow me to run my logic. The Python SDK already has this; see this PR.

@gilmatok
Copy link
Contributor Author

gilmatok commented Mar 16, 2023

As a temporary solution, I just copied the HTML from Slack's default page with dynamic values for the team/app ids:

          res.write(`<!DOCTYPE html>
            <html>
            <head>
            <meta http-equiv="refresh" content="0; URL=slack://app?team=${installation.team.id}&id=${installation.appId}">
            <style>
            body {
              padding: 10px 15px;
              font-family: verdana;
              text-align: center;
            }
            </style>
            </head>
            <body>
            <h2>Thank you!</h2>
            <p>Redirecting to the Slack App... click <a href="slack://app?team=${installation.team.id}&id=${installation.appId}">here</a>. If you use the browser version of Slack, click <a href="https://app.slack.com/client/${installation.team.id}" target="_blank">this link</a> instead.</p>
            </body>
            </html>`);
          res.end();```

@filmaj filmaj added enhancement M-T: A feature request for new functionality and removed untriaged labels Mar 16, 2023
@filmaj
Copy link
Contributor

filmaj commented Mar 16, 2023

Seems like a reasonable feature request, and thanks for posting your workaround!

@filmaj filmaj added the auto-triage-skip Prevent this issue from being closed due to lack of activity label Mar 16, 2023
@filmaj filmaj added this to the 3.x milestone Aug 28, 2024
@filmaj filmaj modified the milestones: 3.x, 4.x Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-triage-skip Prevent this issue from being closed due to lack of activity enhancement M-T: A feature request for new functionality
Projects
None yet
Development

No branches or pull requests

2 participants