0

In the code below, I'm trying to hit an API and it takes about a minute to respond. The issue is that when I click on a button I get the warning symbol as seen in the attached image. How can I fix this?

Code snippet

    new_url = []
    for i in url1:
      if i:
         new_url.append(i)
      else:
          del new_url[-1]

    url = ''.join(new_url)
    print(url)
    r = requests.get(url)
    status = r.status_code


    if str(status) == "500":
        error = r.json()
        msg2 = "" + error[ 'errorMessage' ] + "\n"
        print(msg2)
        send_Failureresponse_to_user(slack_client,channel,thread_ts,user_name,msg2)
    else:
        response = r.json()
        msg = " Order Id - " + response[ 'orderId' ] + "\n First Name - " + response[ 'firstName' ] + "\n Last Name - " + response[
            'lastName' ] + "\n PhoneNumber - " + response[ 'phoneNumber' ] + "\n Email - " + response[ 'emailAddress' ] + "\n"
        print(msg)
        user_threads_info[ user_name ][ 'orderId' ] = response[ 'orderId' ]
        send_response_to_user(slack_client, channel, thread_ts, msg, user_name)
        insert_values(channel, thread_ts, user_name)
        # send_omsresponse_to_user(slack_client, channel, thread_ts)

    return True

enter image description here

DapperDuck
  • 2,728
  • 1
  • 9
  • 21
Rk5
  • 325
  • 1
  • 4
  • 17

1 Answers1

0

To avoid this error, you server should respond to the initial request from Slack within 3000ms. You can then make a call to chat.update to edit the message once your async job has completed.

Colm Doyle
  • 3,598
  • 1
  • 20
  • 22
  • - but the challenge here is that API cannot respond back within 3000ms , so can you let me know if there is any other alternative? thanks! – Rk5 Jan 07 '21 at 21:20
  • Based on what you’ve said, the only option is to acknowledge the request from Slack *before* you call the other API. – Colm Doyle Jan 07 '21 at 21:42