0

I am creating a Slack app in Bolt framework for Python. I successfully created new command, which open new modal window with text input and datepicker.

The problem is, that when trying to submit I receive error: We had some trouble connecting. Try again?

Code:


@app.command("/echo")
def handle_command(body, ack, client, logger):
    logger.info(body)
    ack()
    res = client.views_open(
        trigger_id=body["trigger_id"],
        view={
            "title": {
                "type": "plain_text",
                "text": "Add info to feedback",
                "emoji": True
            },
            "submit": {
                "type": "plain_text",
                "text": "Save",
                "emoji": True
            },
            "type": "modal",
            "callback_id": "view123",
            "blocks": [
                {
                    "type": "input",
                    "element": {
                        "type": "plain_text_input"
                    },
                    "label": {
                        "type": "plain_text",
                        "text": "Label",
                        "emoji": True
                    }
                },
                {
                    "type": "actions",
                    "elements": [
                        {
                            "type": "datepicker",
                            "initial_date": "1990-04-28",
                            "placeholder": {
                                "type": "plain_text",
                                "text": "Select a date",
                                "emoji": True
                            },
                            "action_id": "actionId-0"
                        },
                        {
                            "type": "datepicker",
                            "initial_date": "1990-04-28",
                            "placeholder": {
                                "type": "plain_text",
                                "text": "Select a date",
                                "emoji": True
                            },
                            "action_id": "actionId-1"
                        }
                    ]
                }
            ]
        },
    )
    logger.info(res)

I figured out, that I have to listen to view submission, but don't know how to do it.

It doesn't work:

@app.view("view123")
def handle_submission(ack, body, client, view, logger):
    ack()

Any ideas / suggestions what I am doing wrong?

ZigaK
  • 21
  • 4

1 Answers1

1

(I assume it's too late to help with your project now, but for anyone else who comes across a similar problem:)

It could be an issue of not having the Request URL in Interactivity & Shortcuts set up.

In the Slack App config dashboard, handling slash commands is separately configured from handling interactions with views. They can both point to the same request URL, but you have to individually input it for each feature type.

jnotelddim
  • 1,806
  • 17
  • 32