slackapi/python-slack-sdk

Append `thread_ts` to the payload of a lazy listener in Slash Commands

Closed this issue · 2 comments

Hi!

I am using slash commands with answers that will take more than 3 seconds so I'm using a lazy_listener, e.g. lazy_listener.

I wonder if there's any way to add to the payload the thread_ts of the ack function to the lazy one SlashCommandPayload.json

Reproducible in:

def fetch_data(respond, body):
    data = get(...)
    respond(f"Data: {data}")

def delayed_response(body, say):
   ack()
   # I can append data to the `body` and access it in the `fetch_data` function.
   response = say('Fetching info...')
   # Once I post a message I can access the `thread_ts` from `response`
   # But I can't modify the body here so I can't pass the `thread_ts` to the `fetch_data` function

app.command("/get-data")(
    ack=delayed_response,
    lazy=[fetch_data]
)

Thanks.

Hi @adrianfusco, thanks for asking the question. Lazy listeners do not receive anything from the "ack" listener side. This is by design to prevent the mechanism from being too much complex, so we don't have plans to enhance it.

Instead, I would suggest posting the initial message using say() utility in the lazy listener. With this approach, the "ack" listener just acknowledges the request and does not post any messages. Also, the rest of your lazy listener code can utilize the posted message's ts without any magic.

I hope this helps.

Hi @seratch I appreciate your answer and your time. It works fine!