1

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.

rhysn
  • 11
  • 2
  • Why are you bothering with flask since there's bolt? It's quite easy to set it up with bolt. Also, what error are you getting? – nikolas Nov 17 '22 at 21:54
  • The previous implementation version had flask and I just kept if for now. I imagine this is not necessary. I'm not getting any errors on kubernetes logs but get a gray error message when interacting with the button on slack: "app has not been configured for this feature. please contact the app's developer" – rhysn Nov 21 '22 at 15:18

0 Answers0