Implement delayed Slack slash response
<p>I want to implement slack slash command that has to process fucntion <code>pipeline</code> which takes roughly 30 seconds to process. Now since <a href="https://api.slack.com/slash-commands#responding_to_a_command" rel="nofollow">Slack</a> slash commands only allows 3 seconds to respond, how to go about implementing this. I referred <a href="http://stackoverflow.com/questions/34896954/how-to-avoid-slack-command-timeout-error">this</a> but don't how to implement it. </p>

<p>Please hold up with me. I am doing this first time.
This is what I have tried. I know how to respond with <code>ok status</code> within 3 seconds but I don't understand how to again call <code>pipeline</code></p>

<pre><code>import requests
import json
from bottle import route, run, request
from S3_download import s3_download
from index import main_func

@route('/action')
def action():
        pipeline()
        return "ok"

def pipeline():
        s3_download()
        p = main_func()
        print (p)

if __name__ == "__main__":
      run(host='0.0.0.0', port=8082, debug=True)
</code></pre>

<p>I came across <a href="https://claudiajs.com/tutorials/slack-delayed-responses.html" rel="nofollow">this</a> article. Is using AWS lambda the only solution?
Can't we do this completely in python?</p>

<p>You have an option or two for doing this in a single process, but it's fraught with peril. If you spin up a new <code>Thread</code> to handle the long process, you might end up deploying or crashing in the middle and losing it.</p>

<p>If durability is important to you, look into background-task workers like SQS, Lambda, or even a Celery task queue backed with Redis. A separate task has some interesting failure modes, and these tools will help you deal with them better than just spawning a thread.</p>

python response slack-api slack slash