Skip to content

Get Slack bot tokens after invoking manifest API? #1192

Description

@nyavramov

Hey there,

I'm creating a Slack bot that runs on AWS Lambda and I'd like to automate the process of setting up the bot.

To create the AWS resources the bot will run on, I'm using AWS SAM templates to create a Lambda function and an API gateway. Then I'm using the new Slack manifest API to automate the creation of the app within Slack itself.

In python, I was able to define a manifest for my Slack app:

manifest = {
    "display_information": {
        "name": "",
        "description": "...",
        "background_color": #fff,
    },
    "features": {"bot_user": {"display_name": "", "always_online": True}, "slash_commands": [
        {
            "command": "/my_command",
            "url": "https://www.my_url.com",
            "description": f"...",
            "should_escape": True,
        }
    ]},
    "oauth_config": {
        "scopes": {
            "bot": [
                "commands",
                "channels:history",
                "chat:write",
                "groups:history",
                "incoming-webhook",
            ]
        }
    },
    "settings": {
        "interactivity": {"is_enabled": True, "request_url": "https://www.my_request_url.com"},
        "org_deploy_enabled": True,
        "socket_mode_enabled": False,
        "token_rotation_enabled": False,
    },
}

I was then able to use the manifest API to successfully create the app:

import requests
import os 
import json 

payload = {"token": os.environ["SLACK_TOKEN"], "manifest": json.dumps(manifest)}

r = requests.post(
    url="https://slack.com/api/apps.manifest.create",
    data=payload,
)

I've confirmed that the app appears in the Slack app creation UI. However, my Lambda function needs the bot token for the app I created from the manifest above.

Is there a way I can programmatically get the bot token and update my lambda function?

I want to automate as much of the bot deployment as possible, but I don't know of a good way to put the bot token into my lambda function short of manually logging into the Slack UI itself and copying it from there.

Thanks a bunch!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionM-T: User needs support to use the project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions