Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "We had some trouble connecting. Try again?" when submitting a modal #225

Open
juandecdiaz opened this issue Jul 9, 2021 · 0 comments

Comments

@juandecdiaz
Copy link

juandecdiaz commented Jul 9, 2021

Hi,

I've implemented a slack bot using the Bolt python framework. This bot includes a bunch of shortcuts that perform some actions.

I've made it work in my local by using local proxy ngrok and setting the request URL in the Interactive section to the ngrok URL adding /slack/events at the end. I was running the app on a local server listening to Slack events in that request URL.

...
@app.shortcut("my-shortcut")
def open_modal(ack, shortcut, client, body, logger):
    # Acknowledge the shortcut request
    ack() 
    try:
        result = client.views_open(
            trigger_id=shortcut["trigger_id"],
            # It opens the modal
            view=get_modal_json()
        )     
    except SlackApiError as e:
        logger.error(
           "Error opening the modal: {}".format(e))`


@app.view("my-shortcut")
def modal_submission(ack, body, client, view, logger):
    # Acknowledge the shortcut request
    ack()
   # some actions
   ...

# Start your app
if __name__ == "__main__":
    app.start(port=3000))

So the next step was to deploy in a test environment. For that purpose, I've built and deployed the slack app using Lambda with an API gateway integration.

When I trigger a shortcut a modal is opened with a couple of text boxes where the user will be introducing some values.
The modal is opened successfully as it did in my local, but when I submit the values, I always got the error "We had some trouble connecting. Try again?" when I test with the lambda. In my local, I never got this error.

The actions performed on the submission are performed successfully after submitting the modal but I am always getting this error "We had some trouble connecting. Try again?"

Code is as follows:

...
@app.shortcut("my-shortcut")
def open_modal(ack, shortcut, client, body, logger):
    # Acknowledge the shortcut request
    ack() 
    try:
        result = client.views_open(
            trigger_id=shortcut["trigger_id"],
            # It opens the modal
            view=get_modal_json()
        )     
    except SlackApiError as e:
        logger.error(
            "Error opening the modal: {}".format(e))`


@app.view("my-shortcut")
def modal_submission(ack, body, client, view, logger):
    # Acknowledge the shortcut request
    ack()
   # some actions
   ...


def handler(event, context):
    slack_handler = SlackRequestHandler(app=app)
    return slack_handler.handle(event, context)

I don't see any error in either in the Lambda and in the API Gateway Cloudwatch logs.
Lambda is responding with
[DEBUG] 2021-07-09T13:31:36.360Z 36279b25-9135-478e-a101-ca3822263fa4 Responding with status: 200 body: "" (341 millis)
and the API Gateway also with a 200 response status as follows
(f1c28d03-d61e-4ea5-9d03-8a830a444400) Method response body after transformations: { "statusCode": 200, "body": "", "headers": { "content-type": "text/plain;charset=utf-8" } }

Could you please help with this? I couldn't find any related issue in slack bolt python docs.

image

image

Thanks in advance and kind regards,

Juande

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant