0

I am trying to build a slackbot which communicates with Cloud functions. Where there is an event, slack will send out a POST request and I will do some processing and use the incoming webhook to write to slack channel. However I saw a documentation, which says if you don't respond, they will try again. Hence it seems to be continuously writing because I did not respond. There also seems to be no clear documentation on how I should respond. Is there a clearer documentation? Please advice. Thank you.

enter image description here

https://api.slack.com/events-api

zzamp
  • 31
  • 3
  • Could you please include a bit of detail about how you're handling the POST request from Slack? Are you using any Java frameworks? It sounds like you need to return a response to the incoming POST request. Any response seems to be fine so just respond with a HTTP 200. – Daniel Tung Oct 07 '19 at 14:17
  • It's sending the POST request to IBM Cloud Functions. I don't understand where the to return the HTTP 200 to. There's no link provided, unless maybe it is in the HTTP header? I don't fully understand it. – zzamp Oct 07 '19 at 14:29
  • 1
    Your application is waiting for a POST request from Slack. Much like with a web browser Slack expects to get a response back. An example would be trying to navigate to a website, you send a GET request from your browser to the website server. The website receives the GET request and responds back to your browser with their website. This response contains an HTTP response header. – Daniel Tung Oct 07 '19 at 14:42
  • 1
    By default IBM Cloud Functions will return HTTP 200 back to the requester as long as a response body has been set. Make sure you're setting a return value on your function. – Daniel Tung Oct 07 '19 at 14:46
  • For designing your app make sure that when your app receives an event it responds to Slack first before doing any additional action. A good pattern is to put the event into a queue and have a queue worker (in another process) to perform the action. Or you can start a new thread / process to perform the action. – Erik Kalkoken Oct 10 '19 at 12:26

1 Answers1

2

It's very clearly described what you need to respond with:

Your app should respond to the event request with an HTTP 2xx within three seconds

HTTP 2XX is an indication of an HTTP status code, ranging from 200 to 299 (not all of them exist per the standard). Depending on which framework you are using, you can probably set an HTTP status code in the response of a web request. Body of your response doesn't seem to matter, as long as it is an HTTP 2XX status code.

List of HTTP 2XX status codes

Elias
  • 1,532
  • 8
  • 19