How can I mute a slack channel/group using slack API? - slack

I'm trying to mute notifications particular group in Slack workspace. Is there any API method available to do?
I've tried using the web-API method mentioned in this GitHub page https://github.com/ErikKalkoken/slackApiDoc/blob/master/users.prefs.set.md.
It causes no error in response but the channels I provided in the 'muted_channels' parameter wasn't muted.

In my case, I didn't have to send a prefs payload as ErikKalkoken described, but instead this one. Found it out thanks to this Tweet: https://twitter.com/slackhq/status/457711460425027584
{
"name": "plain_text_mode",
"value": True
}

Related

Unable to successfully upload a file via Slack API

I'm unable to successfully upload a file even using Slacks file.upload tester mechanism here: https://api.slack.com/methods/files.upload
I've applied a Slack app token, channel name, and chosen a file, but get the following result:
{
"ok": false,
"error": "missing_scope",
"needed": "files:write:user",
"provided": "identify,incoming-webhook"
}
I then created a new app, and ensured that files: write was in scope (it wasn't in the previous app). Now, I get a different error:
{
"ok": false,
"error": "not_in_channel"
}
As a test to confirm that the channel name was ok, I subsequently tried a nonexistent channel name, and the error indicated 'channel_not_found', so the channel name I used should be valid.
I had the same issue and fixed it by adding the Slack app to the channel
I guess there are many ways to add it;
I just opened the corresponding channel I was trying to "files.upload" to, and clicked the "Add an app" link at the really top of the channel history:
Before posting a message, reacting to any message or uploading files you need to open a conversation with the channel. You can also do it programmatically and achieve this with the help of API (https://api.slack.com/methods/conversations.open)
You just need to invite the app that you created into the slack channel. Example:
#AppBot

Can Botframework add a reaction to a user message?

Can bot add a reaction to a user message?
I tried to send an activity like this:
{
"type": "messageReaction",
"reactionsAdded": [{ "type": "like" }],
"replyToId": 1579278444192
}
on this URL - /v3/conversations/{conversationId}/activities/{activityId}
It depends entirely on the channel you are wanting to implement this on. If channel x (Facebook, Slack, etc.) sends "reactions" as part of the activity and the service allows you to scope to it, then it is possible to return bot responses based on those.
The Botbuilder-Samples GitHub 25.message-reaction Javascript sample demonstrates how this is achieved for Teams. The C# version can be referenced here. You would need to adjust the code to look for the appropriate context/activity data points and filter on those to send a response back.
Hope of help!

Are AdaptiveCards supported with MS Teams & the WebHook Connector?

Each time I try to send any example json from the documentation I get a HTTP 400 saying that "summary" or "text" is missing (which is indeed the case), however once I make a successful request, Teams displays an empty card
Is this thing supported at all??
Late answer, still, today with Postman app, I was able to post an adaptive card json as a message attachment to Teams incoming webhook [1] url. Microsoft Documentation is also available at link.
Looks like still, webhooks are not supporting adaptiveCards. But there is a trick to send adaptive cards via incoming webhooks like below,
Note: ${Replace it with Your AdapticveCARDShema Json Payload} would be your adaptive card Json payload
{
"type":"message",
"attachments":[
{
"contentType":"application/vnd.microsoft.card.adaptive",
"contentUrl":"null",
"content":{
${Replace it with Your AdapticveCARDShema Json Payload}
}
}
]
}
Webhooks do not yet support Adaptive Cards. We plan to add support for Adaptive Cards shortly.

Hot to enable Cloud Elements Microsoft Graph Calendar webhooks for all calendars?

By default, when I integrate my Microsoft account with cloud elements:
https://developers.cloud-elements.com/docs/elements/microsoftgraph/
I only get notifications for my default calendar. But, in fact, I have like 5+ calendars. I want to get notifications about changes in all of them.
For now, I can only think of making a new end-point that accepts calendar ID and then I invoke this endpoint with the result of invocation:
GET /calendars
But, this looks like a hack. Is there a better solution to listen to all the calendars that I have using Cloud Elements?
According to your description, I assume you want to get the notifications for your calendar when the calendar changed.
We can use the subscription endpoint to get the notifications. For more detail about this endpoint, we can refer to this document
In the Cloud Elements UI, if you select the instance and click the api docs you will see four sections "information", "setup", "resources", and "models". Select resources and you will see one that has POST /webhooks
This is the call the Cloud Elements sends on webhook provision. If you want to change the body of the webhook go to the PreRequest Hook where you will see javascript that is creating a post body that will be sent to Microsoft.
By default the body you see in the javascript looks like:
var body={
"changeType": "created,updated,deleted",
"notificationUrl": "{webhookCallbackUrl}",
"resource": "/me/events",
"expirationDateTime": newDate
}
If you want to change what resources you get notification for you can do so in this body and using the documentation that was provided in the previous answer

Ephemeral Responses in Slack for BotFramework

I'm new to the Botframework, but am making some great headway. I've got a bot up and running and it works great for DM chats in Slack, but I'd like my bot's responses to be only to asking user in a chatroom/group instead being broadcast to the group.
Reading up on Slack, it looks like if I set the response_type to "ephemeral", this should solve the problem. Sounds potentially easy enough, but no idea if we have the ability to override this in the dialog context / activity. Any suggestions?
If you take a look at the NodeJS SDK Documentation for Sessions and scroll down to the Cards section, you will find a handy little function of the Message class
Message.sourceEvent()
From the same documentation page:
It’s not practical for the SDK to support every card or attachment
format supported by the underlying chat service so we have a
Message.sourceEvent() method that you can use to send custom messages
& attachments in the channel native schema.
Which means that you can use Message.sourceEvent() to do exactly what you are trying do: alter the structure of your outgoing message object.
Here is a code snippet for your specific case that I tried out:
//test slack source event messaging
var msg = new botbuilder.Message(session).sourceEvent({
slack: {
response_type: "ephemeral",
text: "This is a test Slack message.",
attachments: [
{
text: "Test inlaid message."
}
]
}
});
When you pass the current session to the Message() class, it populates all the address info in the Message so you don't have to do any of that. You can see for yourself here in the documentation for the Message's constructor method.
Then, you just call sourceEvent() and pass in an object, with the name of the channel you are constructing a message for (in this case slack), and then fill out the desired message data. This allows you to define your response_type: "ephemeral".
Documentation for sourceEvent() here.

Resources