How can i provide a delete URL to a message to the user in slack? - slack

I want my bot to post a message to a user which has a "delete" link to a particular message posted by that user. For e.g.
"Hi #someuser , you have posted an inappropriate message. Click >>here<< to delete it."
When the user clicks on "here" it will open up the slack delete message UI?
I have the message ts and channel ID.
I know i can do this via chat.delete api call (have the link point to my backend and then issue the chat.delete api call).
But i was wondering if there is a way to point user to the "delete message" window via a direct link in the message itself.

You can not add to or change the existing message of another user. Only delete a message (with admin rights).
What you can do though is send the guy a direct message from your app including the link (or button) to delete the message. Just send a message to the user ID of the user via chat.postMessage.
Or you can send the guy an ephemeral message into the channel, that only he will be able to see with chat.postEphermal.
To create a user experience similar to Slack's delete pop-up for messages I would suggest the following:
Include a "Delete" button in your message to the user with the
danger style, so it is shown in red color.
Include a confirmation pop-up with a copy of the message text.

Related

Slack API: Is there a way to determine which user clicked on a button in an interactive message?

I am new to Slack's API, so bear with me. I have a slack button that contains a simple webhook link which, when clicked, updates a record somewhere on my site. However, I need to determine which user clicked the button and send this info back to my site in order to fill out an updated_by field with the user's name. The only way I see to do this is to somehow update the post request body with a variable containing the user's name?
You need to handle interaction with the buttton.
https://api.slack.com/reference/interaction-payloads/block-actions
The payload received contains the SlackId of the user who clicked the button.

Slack API - clicking a button in a Slack conversation sends a message on the channel

In a Slack conversation, is it possible to click on a button to send a message to the Slack channel?
The Slack conversation could be:
The user types a word (or message)
A slackbot shows some text and two buttons
The user clicks on a button to send a TEXT message to the Slack channel
The Slackbot reacts on the 'action' message.
It is not possible to create an REST service for my Slackbot, because the Slackbot is behind a firewall. So, registering commands is not possible.
So sending a message as the result of a button click is needed. The Slackbot can react on that message.
I read that attachments could be a good way to do this, BUT the is 'outmoded'.
I tried to send an secondary attachment, which is outmoded, but that was not possible.
The next approach was adding a webhook. So pushing a button resulted in using the url, but that is of course not possible because I cannot send a POST request via a simple (get) url.
Please give a short example.
This will not work.
Every interactive feature (e.g. buttons) require your app to be able to receive POST requests from Slack through the public Internet. Since you say you can not provide that (e.g. behind a company firewall) you will not be able to use any interactive features.
See also this answer: How to integrate internal APIs (Not accessible outside office network) to slack slash commands

create a slack message and edit before sending

I have created a bot using Botkit and am working on creating an interactive message. What I want to do is when the user clicks on the button in the interactive message, a new message will be created pulling som info from the original interactive message, BUT WILL NOT BE SENT. I need to continue editing the message before choosing to send it. Does anybody know whether this is possible or not? I have been googling and searching slack's docs and botkit's docs, but haven't been able to find an answer.
If you want to let the user edit a message before sending you can use the Dialog feature from Slack. It will allow you to show an input text field, where the user can make his edits. I am not familiar with Botkit though and can not say if it supports Dialogs.

Slack respond to dialog submission with another dialog

Is there any way in the Slack API to have the submission button of a dialog open a new dialog or edit the current one?
Not directly. You can use the response_url attached to the dialog submission sent to your server to then post a follow up ephemeral message to the user, containing a button to continue to the next dialog. Once clicked, you'll receive another trigger_id which you can send to dialog.open and start another dialog.
More information on triggers and where to find them can be found here.

Send push message to users encouraging leaving itunes feedback

How do you link to your itunes review site in a Parse push message, is that even possible?
You have two options:
Option 1) First, create a custom activity in your app and all that activity should do is automatically open up the link to the whatever website/iTunes/app store product you want them to review.
Then, you can set your push notification via Parse to open that activity when the user clicks on it. See the section called "Responding with a Custom Activity" at this link. https://parse.com/tutorials/android-push-notifications
Option 2) At the same link, see the section for Responding with a Custom URI and simply use the URI to direct them to your website/iTunes/app store/etc. https://parse.com/tutorials/android-push-notifications

Resources