Slack Bolt - Send response when button is clicked / app has not been configured

1k views Asked by At

I'm very new to creating a slackbot and was hoping for some help from the community!

I'm using Python to create a slackbot that schedules a message to a channel every week. The mentioned user in the channel then should be able to click either confirm or skip. The slackbot server is currently running on kubernetes.

I've been able to schedule a message using a CronTrigger every week. However I am having trouble listening to the button response from slack bolt action. When I click on the message, I get a gray warning saying "App has not been configured for this feature".

This is what the message looks like:

[
{
    "type": "actions",
    "elements": [
        {
            "type": "button",
            "text": {
                "type": "plain_text",
                "text": "Confirm!",
                "emoji": True,
            },
            "value": "confirm",
            "action_id": "actionId-0",
        },
        {
            "type": "button",
            "text": {
                "type": "plain_text",
                "text": "Skip Me!",
                "emoji": True,
            },
            "value": "skip",
            "action_id": "actionId-1",
        }
    ],
}
]

In my app class, I have a flask_app running as such:

app = App()

# Initialize web server and Slack client
client = WebClient(
    token=os.environ.get("SLACK_BOT_TOKEN"), proxy=os.environ.get("HTTP_PROXY")
)

flask_app = Flask(__name__)
handler = SlackRequestHandler(app)


@flask_app.route("/slack/events", methods=["POST"])
def slack_events():
    return handler.handle(request)

And for each of the button, I'm trying to have a custom response sent as such

@app.action("actionId-0")
def button_confirm():
    logging.info("hit confirm!")
    current_user_id = scheduler.current_contact()
    message_block = mybot.get_confirm_message_block(current_user_id)

    logging.info("Initializing confirm message....")
    try:
        client.chat_postMessage(
            channel=os.environ.get("SLACK_CHANNEL"),
            blocks=message_block,
        )
        logging.info(f"Sending blocks {message_block}...")
    except SlackApiError as e:
        logging.error("Error confirming message: {}".format(e))
    pass

I'm not sure what I'm doing wrong and would very much appreciate any help debugging. I'm still trying my best to learn how everything works :)

Thanks

I've tried running without the flask app and was not successful. I've looked into a bunch of api documents and online resources but I feel like I'm missing something.

0

There are 0 answers