Slack POSTing to response_url only shows a message visible only to me instead of updating or editing original message - slack

My bot responds quickly to a slash command /test and the message is publicly visible in the channel for everyone:
{
"response_type": "in_channel",
"text": "Please Wait, Processing..."
}
the message the bot sends to the chat
Then I try to respond with response_url The message appears only for me
screenshot of what I see
I POST the response_url with:
{
"replace_original": "true",
"text": "This is the result! Thanks for waiting for them"
}
It only shows for me as a new message instead of editing/updating the old message
I want it to edit the message the bot sent in the first message, in other words update the message with the result, and for it to be public. I don't know why it only shows for me in a new message instead of updating the message itself?

Related

How to add my slack bot's message to a user's message?

Here's what I need,
A user sends a message, and my slack bot return a message that should be attached to the specific user, whose message I processed.
The image below explains it clearly, the user named Changming sends a message in Chinese, and then the slack app attaches it's translation in English, to the original message. How can I do that?
Until now, I've been able to send a block in a message, but I don't know how to attach it to the original message.
As the problem occurs, if there are multiple messages being sent in a single second, then the bot's messaged will not be in the correct position, as the bot will also take certain amount of time in processing and sending the messages back to slack.

How can i provide a delete URL to a message to the user in 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.

response to conversationUpdate on Skype for Business

I intend to send a greeting message from the bot on Skype for Business when the user initially opens the chat window. To achieve this I'm trying to respond to the conversationUpdate event from the bot. When I respond to the conversationUpdate event, i receive the following error that conversation does not exits
{"Error":{"Code":"ServiceError","Message":"Conversation does not
exist"}}
But when the same user sends a message, I receive the message with the same conversationId and am able to respond back without any issues.
I'm able to do this without any issues on the web chat but not on SfB. I looked at some issues on Microsoft's GitHub repository for the bot, which suggested that the question may be best answered on SO.
Updates
I was earlier on SfB 2013. I've upgraded to SfB 2016 and the bot responds to the conversationUpdate event it receives once the user sends his first message. Usually on a web chat, the response to the first conversationUpdate is sent as soon as the user opens the window and a second response is sent once the user sends his first message. In the case of SfB, the response to second conversationUpdate is working but not for the first conversationUpdate.
Web Chat
Skype for Business
As explained above, the response to first conversationUpdate will result in the
Conversation does not exist
error. The response to the second conversationUpdate when user sends his first message works.
So now how do we make the welcome message work for the first conversationUpdate and disable it for the second conversationUpdate update ?
I am not sure, why converstaionUpdate event didn't triggered. But as mentioned in BotFramework docs, not every channels supports that event. You can add a first run dialog instead and check if that works. Adding a sample from the docs page:
// Add first run dialog
bot.dialog('firstRun', function (session) {
session.userData.firstRun = true;
session.send("Hello...").endDialog();
}).triggerAction({
onFindAction: function (context, callback) {
// Only trigger if we've never seen user before
if (!context.userData.firstRun) {
// Return a score of 1.1 to ensure the first run dialog wins
callback(null, 1.1);
} else {
callback(null, 0.0);
}
}
});

Delete interactive message (command response) just with Slack Commands API

So I'm building a slack app in Node that responds to some user commands. It usually responds with an interactive message that has some attachments and buttons.
For certain buttons, I return different types of texts or other attachments, but I also want to have a "Cancel" button that would basically cancel the current command - delete it from the user's chat.
The thing is that I want to do it without having to request the chat:write:user scope or without having to create a bot.
By asking for the chat:write:user scope I can basically remove any message the user created, but it asks for that scope when installing the app and gives my app permission to post on behalf of the user, which most find uncomfortable.
By creating a bot I could achieve this, but again it asks for permission to add a bot to the channel and I don't want this.
What I've tried
Use chat.delete method, but I get { ok: false, error: 'missing_scope', needed: 'chat:write:user', provided: 'identify,commands' } from Slack, even when I try with as_user set to false.
Respond with an empty message to the command, like res.send(), or res.send({ text: null }), or res.send({ attachments: null }), etc.
When you reply to a user command on Slack it overrides by default the previous content. I just want to override with nothing, basically removing the original response. When I try this however, it doesn't do anything, unless I provide some content.
I'm pretty sure #2 is the way to go and I feel I'm close and it's something pretty simple but out of my sight.
Working example of what I want
I know it can be done because the GIF Keyboard app for slack does this. When searching for Gifs, they have a "cancel" button at the bottom that just removes the current command/message. Furthermore, they only ask for the Commands scope.
You are on the right track. Option #2 works, so no need to request scopes to delete a message.
Just send the following response back to Slack and the last (ephemeral) message from your app will be deleted:
{
"response_type": "ephemeral",
"replace_original": true,
"delete_original": true,
"text": ""
}

Can't send message to some bot users in Telegram

I made the bot in telegram which accepts some requests from users. My bot should send notifications about changes of the request status. I do it separate from my script by sending get request. But some users can not get the notification message, because this error "{
"ok": false,
"error_code": 403,
"description": "Forbidden: bot was blocked by the user"
}" The user didn't block the bot. The bot blocked itself for some reason. I can't understand how it happens. What is the reason of blocking bot by the user unconsciously? I want write the guid for user "how do not block bot", but I don't know the reason. How I can solve this issue?
Here's my request:
https://api.telegram.org/bot<bot_token>/sendMessage?chat_id=<chat_id>&text=<Your request status changed>&reply_markup={"inline_keyboard": [[{"text": "View", "callback_data": "<request_id>"}]]}
Your bot is blocked by users yet, need to click RESTART to unblock bot.
You can try it yourself by click Stop Bot in menu.
I had the same problem, revoking bot's token solved it.

Resources