Say() does not provide a response_url for the message it posts
Reproducible in:
The slack_bolt version
1.14.3
Python runtime version
Python 3.10.4
OS info
ProductName: macOS ProductVersion: 12.5 BuildVersion: 21G72
Steps to reproduce:
I am making a bot to create release notes within our slack environment.
- The user enters the triggering command in slack.
- The bot uses the Say() method to post the release notes.
- The bot does additional processing, and I would like to modify the release notes post with a link to the pull request. The Say() return value doesn't seem to provide enough information to call Respond() with "replace_original = True".
- There is a Refresh button on the release notes post, and clicking calls a Respond() that does work.
Expected result:
I would expect that Say() returns whatever is needed to modify the said message. I need to be able to modify a message that hasn't received any user interaction.
Actual result:
Say() does not return the necessary information. I get the following error when trying to update the original message without any user interaction: "respond is unsupported here as there is no response_url"
Hi @ChrisPage-AT thanks for writing in!
Under the hood Say() uses the client.chat_postMessage method this returns an object containing information about the message
What I believe you are looking for is the "ts" value in this payload, this allows slack to identify your message in a channel and perform various operations on it like deleting and updating.
Hopefully this helps you on your journey 🧭
How do I go about using that "ts" value to update a message? I know how to use "ts" to reply in a thread but trying to use app.client.chat_update requires the channel id, and that isn't returned by Say() either.
Bolt python uses keyword injection to parse the request and provide functions and data to the developers, here are 2 parameters that allow you to recover the channel_id, first through the context or directly with its parameter channel_id
here is an example:
@app.command("sample")
def sample_command(command, context, channel_id, ack: Ack, say: Say, logger: Logger):
try:
ack()
say(
f"this is my channel {context.channel_id} and here it is again {channel_id}"
)
except Exception as e:
logger.error(e)
👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.
As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.