I have a bot app that sends a message to the slack channel. I am using https://api.slack.com/methods/chat.postMessage/ to send messages to the slack channel.
My message sometimes has few links (GIF) which are being rendered in the channel as a plain link.
I want them to be unfurled so that it can display animated GIF on the channel itself.
I tried passing unfurl_links: true to the API parameter however it doesn't work.
Here is my JSON payload
{
"text": "Anniversary Alert :confetti_ball:",
"channel": "C01AGGP63ST",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Anniversary Alert :confetti_ball:\n\nLet's all take a moment to congratulate <#U024FCGPW> on their 10 year anniversary!\n\nWe wish you a very happy anniversary and many more great years ahead with us.\n\nhttps://media0.giphy.com/media/1yjpDZgvGkb6nTynq3/giphy.gif?cid=cbd9d2f95475c686b1a293a6cf43de5f3f640e4eb012f714&rid=giphy.gif"
}
}
],
unfurl_links: true
}
Can someone please help?
Used "attachments" property of the API payload and it unfurls the link
{
"text": "Anniversary Alert :confetti_ball:",
"channel": "C01AGGP63ST",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Anniversary Alert :confetti_ball:\n\nLet's all take a moment to congratulate <#U024FCGPW> on their 10 year anniversary!\n\nWe wish you a very happy anniversary and many more great years ahead with us.\n\nhttps://media0.giphy.com/media/1yjpDZgvGkb6nTynq3/giphy.gif?cid=cbd9d2f95475c686b1a293a6cf43de5f3f640e4eb012f714&rid=giphy.gif"
}
}
],
"attachments": [
{
"text": "",
"image_url": "https://media0.giphy.com/media/1yjpDZgvGkb6nTynq3/giphy.gif?cid=cbd9d2f95475c686b1a293a6cf43de5f3f640e4eb012f714&rid=giphy.gif"
}
]
}
The big gotcha here is that slack unfurl is only triggered when it's a user (bots do not trigger unfurls). Too bad - I'm running into the same issue - unfurl was going to be the way to go but I missed the fine print. I think I'm going to just go with a chat threaded reply (which is way less pretty).
Related
I can see that logic app has Microsoft teams "Post a choice options as the Flow bot to a user" action. However, I would like something where I can present options to a group chat or channel. The reason for not sending multiple individual messages are because I would like only 1 person to response in first come first serve kind of way.
Is there any way I can achieve this?
I can see that logic app has Microsoft teams "Post a choice option as the Flow bot to a user
Yes, you can use Post a choice of options as the flow bot to a user connector in logic Apps to present options to a user as shown in below images.
I would like something where I can present options to a group chat or channel.
But if you want to present options to a group chat or channel AFAIK there is no such built-in connector available in logic Apps. You can achieve this using Adaptive cards.
Adaptive cards for Microsoft teams
By following this document, you can add radio buttons or by changing test as an option you can create buttons labeled option1 and option2 as per your requirement.
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Text Block",
"text": "Please select an option:"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Option 1",
"data": {
"id": "option1"
}
},
{
"type": "Action.Submit",
"title": "Option 2",
"data": {
"id": "option2"
}
},
]
}
Reference link
I am creating a simple MS Teams messaging bot that requires auth/sign-in.
I am using https://smba.trafficmanager.net/amer/v3/conversations/{conversationId}/activities to send a non-reply bot message to user that includes a hero card with a sign-in button.
The body looks somewhat like this:
{
"type": "message",
"from": {
"id": "abc",
"name": "messaging-bot"
},
"conversation": {
"id": "789",
"name": "test",
"tenantId": "456",
"role": "bot",
"conversationType": "personal"
},
"recipient": {
"id": "123",
"name": "test"
},
"attachments": [
{
"contentType": "application/vnd.microsoft.card.hero",
"content": {
"title": "title goes here",
"subtitle": "subtitle goes here",
"text": "descriptive text goes here",
"buttons": [
{
"type": "signin",
"title": "Click me to sign in",
"value": "<my-signin-url>"
}
]
}
}
]
}
When user receives hero card and clicks sign in button, user gets the following error:
This action can't be performed since the app does not exist or has been uninstalled.
I have added my sign-in domain to valid domains, and uploaded app package to MS Teams, so not sure why I am getting this error.
The app is created through Developer Portal in Ms Teams. For now, we are just creating a simple messaging app that relies on the bot messaging endpoint
May someone help with this?
If you are using Microsoft AD, Please add below in valid domain section of your app manifest:
token.botframework.com
login.microsoftonline.com
Quick update on answer. I found that installing/uninstalling app when sideloading app is a bit buggy. Things worked after I closed my MS Teams client and re-opened it
When I send multiple images via api using blocks like this:
{
"blocks": [
{
"type": "image",
"title": {
"type": "plain_text",
"text": "Please enjoy this photo of a kitten"
},
"image_url": "http://placekitten.com/500/500",
"alt_text": "An incredibly cute kitten."
},
{
"type": "image",
"title": {
"type": "plain_text",
"text": "Please enjoy this photo of a kitten"
},
"image_url": "http://placekitten.com/500/500",
"alt_text": "An incredibly cute kitten."
},
{
"type": "image",
"title": {
"type": "plain_text",
"text": "Please enjoy this photo of a kitten"
},
"image_url": "http://placekitten.com/500/500",
"alt_text": "An incredibly cute kitten."
}
]
}
Slack shows them like a separate blocks and doesn't combine them into a gallery:
slack screenshot - API
When I upload them using Slack app in one message - it combines them into a gallery:
slack screenshot - with gallery
I've tried blocks, attachments, third-party urls, permalinks after file.upload - the result is the same, Slack doesn't combine them into gallery.
So, the question is - how do I make it that Slack shows several images in a gallery?
UPD:
Just got an answer from Slack developers support:
slack dev support answer screenshot
Unfortunately, horizontal/gallery formatting of images is not possible
using the block kit builder. However, I'm going to go ahead and pass
your email on to our product team so that they can take this into
consideration for future updates.
Based on your comment,
[...] permalinks after file.upload [...]
this related answer might help (I also added this clarification there).
When uploading files and collecting their permalinks, you must link them in the text param in the message payload (putting them in a mrkdwn block in the blocks param will not work).
In javascript, this looks like:
const result1 = await web.files.upload({...})
const result2 = await web.files.upload({...})
await web.chat.postMessage({
text: `Here are files in a gallery view <${result1.file.permalink| ><${result2.file.permalink| >`,
...
})
I've created an issue that follows this workflow:
When I call rest/api/2/issue/<issue-id>/transitions after creating an issue (which is in OPEN status now) it returns the following JSON:
{
"expand": "transitions",
"transitions": [
{
"id": "4",
"name": "Start Progress",
"to": {
"self": "URL",
"description": "This issue is being actively worked on at the moment by the assignee.",
"iconUrl": "URL",
"name": "In Progress",
"id": "3",
"statusCategory": {
"self": "URL",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
},
"fields": {}
}
]
}
When I make the same call after I change the issue status to "IN PROGRESS" I get back
{
"expand": "transitions",
"transitions": []
}
My questions are:
In the first response shown above, I expected the transitions to "CLOSED" and "RESOLVED" along with the one to "IN PROGRESS". But I only get back the one leading to "IN PROGRESS". Why?
I expected the second response to contain the transitions to "CLOSED", "RESOLVED" and "OPEN", but it returns an empty array. Why?
Please explain the responses from this API
What call should I make to get the next possible transitions?
This is probably a permission issue. The API only shows the transitions that are available to the current user, thus if you are not allowed to execute the CLOSE or RESOLVE transitions due to conditions in the project workflow, they will not appear in the JSON object.
See getTransitions from the JIRA REST API :
Get a list of the transitions possible for this issue by the current user, along with fields that are required and their types.
In order to get the transitions, you can either log in with an account that has the required permissions (check the corresponding workflow) or modify the conditions of the transition in this workflow.
I am sending the users a slack message with a button through a Slack App. On every click of the button, I generate a new URL.
At the moment, I am able to return the URL back as a message. The user clicks on the message to open the URL in the browser.
Instead of the sending a message back, I want to open the URL directly in the browser using slack API.
How can I accomplish it? I can't seem to find anything in the documentation that does that.
Thanks
PS: Google Drive integration does that already.
It appears Slack introduced this feature recently.
As documented in https://api.slack.com/docs/message-attachments#link_buttons
"actions": [
{
"type": "button",
"text": "Book flights 🛫",
"url": "https://flights.example.com/book/r123456"
}
It's possible to preview in Slack's interactive message builder
Unfortunately slack does not support opening urls from message buttons.
You can monitor what slack is planning on releasing here though: https://trello.com/b/ZnTQyumQ/slack-platform-roadmap-for-developers :)
According to Slack, message attachments is the "old way" of composing messages, which will be deprecated in favour of the new Block Kit API.
I found this example on how to do button links on their docs, using the actions object in the message payload.
I haven't implemented it yet, but you can send the message to a channel in your workspace straight from the docs and try it, and it does open the link in the browser as expected.
Update 04/2022
{
"blocks": [
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "View",
"emoji": true
},
"style": "primary",
"url": "https://flights.example.com/book/r123456"
}
]
}
]
}
Test on Slack Blockit Builder: Link