1

I would like send a custom message to a channel, directly after a Slack app installation on the workspace.

I don't find a way to get "install" event installation.

So I thought to use bot user to send a message after the channel creation, but I found nothing about that neither...

Is there a trick to do that?

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114
cmii
  • 3,556
  • 8
  • 38
  • 69
  • What do you mean by "installation on this channel" ? You can only install a Slack app to a workspace, not to a channel. Unless you are talking about so called "workspace apps", which are deprecated. – Erik Kalkoken Oct 18 '19 at 10:19
  • @ErikKalkoken, sorry I misspoked. Yes I'm talking about installation on workspace, but I need to post the message on a specific channel. – cmii Oct 18 '19 at 10:23

2 Answers2

1

There is no installation event, but you don't need one. If you want to send a message after installation of you app to a workspace just add that function at the end of your installation script. e.g. right after you receive the new token for the workspace.

A popular approach is to send the "welcome message" in the app channel. Check out this post about how to do that.

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114
0

I was trying to figure this out myself within the Bolt framework. Here's how I've done it for the OAuth flow:

def success(args: SuccessArgs) -> BoltResponse:
    assert args.request is not None

    team_client = WebClient(token=args.installation.bot_token)

    team_client.chat_postMessage(channel=args.installation.user_id, text="Welcome!")

    return args.default.success(args)


def failure(args: FailureArgs) -> BoltResponse:
    assert args.request is not None
    assert args.reason is not None

    return args.default.failure(args)


callback_options = CallbackOptions(success=success, failure=failure)

oauth_settings = OAuthSettings(
    # …
    callback_options=callback_options
)
Aleš Oskar Kocur
  • 1,381
  • 1
  • 13
  • 29