I feel like I am missing out some parts, but I could not figure out and will require some help here.
I have a slack button to receive user's response and this response will trigger another block message and I intend to send this block as a new message to slack.
However, this ended up returning an empty body to slack.
Is there a way for me to post a new message to slack base on user's response through the interactive button?
This is the function that will send message out to slack
SLACK_URL = "https://slack.com/api/chat.postMessage" # use postMessage if we want visible for everybody, postEphemeral private view
channel_id = channel
user = user
bot_token = os.environ["BOT_TOKEN"]
data = urllib.parse.urlencode({
"token": bot_token,
"channel": channel_id,
"attachments": json.dumps(block),
"user": user,
"link_names": True
})
data = data.encode("ascii")
request = urllib.request.Request(SLACK_URL, data=data, method="POST")
request.add_header( "Content-Type", "application/x-www-form-urlencoded" )
res = urllib.request.urlopen(request).read()
print('res:', res)
This is the response I see from my logs, which return empty to slack
"attachments": [
{
"id": 1,
"fallback": "[no preview available]"
}
All my block kit code are all from slack block kit builder