0

[enter image description here](https://i.stack.imgur.com/tigRC.png)

How to send a message or put text to text area of slack but not autoposting ? I am creating an slack app but unable to find such method or events ? Please create or help me coding

         response = client.chat_postMessage(
            channel="#general",

in this type of format

As I have metnioned problem in upper side, I just want to put or send message from flask to text area without autoposting where later user will check review and might autopost if he wants

user190245
  • 1,027
  • 1
  • 15
  • 31

1 Answers1

0

The Slack API does not provide a way to pre-fill a user's message box. If you're looking to provide a user with a default message that they might choose to send, you could simply send it to them as a dm which they could copy and paste. You could also send the user an interactive BlockKit message containing the proposed message and a button that will automatically send the message when pressed.

Imagine a set of blocks like this

{
    "blocks": [
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "*Proposed Message*\nThis is a message that you might want to send."
            }
        },
        {
            "type": "actions",
            "elements": [
                {
                    "type": "button",
                    "text": {
                        "type": "plain_text",
                        "text": "Send!",
                        "emoji": True
                    },
                    "value": "This is a message that you might want to send.",
                    "action_id": "send_button_pressed"
                }
            ]
        }
    ]
}

and a listener like this

@app.action("send_button_pressed")
def handleSendPressed(ack, body):
    ack()
    generalChannelID = "C123456"
    message = body["actions"][0]["value"]
    client.chat_postMessage(channel=generalChannelID, text=message)

If you need the message to appear as if it came from the user, you'll need to specify a slack app user token and have the scope chat:write:user.

cborch
  • 21
  • 1
  • 4