Microsoft Flow/Teams Adaptive Card - microsoft-teams

Tried using the new adaptive cards feature in Teams that is supposedly live in Flow. Copied the JSON from the Adaptive Card builder online, replaced some strings with string responses from a Form hook. Don't see any reason why I would be seeing this error:
"error": {
"code": "MissingOrInvalidBotAdaptiveCardRequest",
"message": "The specified Teams flowbot adaptive card request is missing or invalid."
}
I have the flow bot enabled in the team and channel that I want the card to display in. I can't figure out what's gone wrong. Everything is entered as a string, right? It would be nice if they updated the documentation on both adaptive card posts and mentions in the Flow/Teams documentation. I'm happy to clarify, I just don't know what to include.

I didn't have the permissions Flow needed in Teams. Once I resolved that and a syntax issue, everything worked out fine. Flow gives the same error whether you don't have permission or there's a syntax/schema problem in your post.

Related

Mark an Adaptive card posted via Incoming webhook in MS Teams as done

We get messages/tasks from an external PHP-server via incoming webhook in a Teams channel. They are posted in the Adaptive Card format using the 'message with attachments' method.
I would like to find a possibility to mark these messages as done.
My idea would be that the message has a button, that turns green and maybe changes the text when clicked. This has to be permanent. Also the text of the card should be hidden.
I tried to implement a button that toggles the visibility of the card, but it turns out the toggle is not persistent but gets reset every time the channel is opened.
As a workaround we are using reactions at the moment, but I would like to find a more obvious way.
Obviously an incoming webhook does not support the use of Action.Submit (as stated in the link above). So I cannot obviously update the card with this method.
I was thinking to use the Post adaptive card and await answer -method from Flow, but it cannot post an answer to a post, but only post a new card, so the context is missing, which of the posts in the channel you ant to mark as done.
A Power automate Flow could achieve this, if it could be told to alter the posted message.
I realize that it is actually a Task I want to post, not necessarily a message/card in a Teams channel. But there seems no way to post a new task directly to a Tasks tab in a Teams channel via an incoming webhook?
Has anybody an idea what technique could be used to achieve my goal?
This is possible using Actions with O365 connector card format, and is not a currently supported feature in Adaptive cards,
Ref Doc: ⁠Create and send messages - Teams | Microsoft Docs
Could you please raise an User Voice

Can you use Power Automate to Repost an Adaptive Card Bot Post to Another Channel?

I've built a Power Automate flow that posts an adaptive card to a channel I've designated as a "Notification" channel. Sometimes these notifications require discussion but to avoid the order changing in Teams and new notifications being buried I've locked the channel.
I've built a "For a selected Message" Instant flow which can copy a selected message to another channel, but it fails any time I attempt to copy the contents of the message and I can only post a link.
The Adaptive card itself is good, I just can't use the copy plain text or copy post dynamic variables without an error in the flow saying 'the adaptive card is invalid'. This would be caused by attempting to post what is effectively one adaptive card inside of another.
Does anyone have a solution for this or have an idea of where I could find a work around?

How do I change the Adaptive card once the user input is submitted?

Though there were few questions regarding the similar, I don't see any working solution.
I am working on a BOT for a feedback. Currently the user is able to send multiple responses by clicking on the options provided in the adaptive card. I am trying to replace the adaptive card with a plain adaptive card that just has some plain text like , "You have chosen option 3".
The following from the link provided in above comments by subbu helps in resolving the same.
var activity = MessageFactory.Attachment(card.ToAttachment());
activity.Id = turnContext.Activity.ReplyToId;
await turnContext.UpdateActivityAsync(activity, cancellationToken);
We went with just deleting the card & sending a default response once user submits as that was enough.

retrieve members email from 1:1 conversation bot framework message extension

So i created a message extension using bot framework v4.
What am trying to do is to retrieve members emails in 1:1 conversation using the message extension on OnTeamsMessagingExtensionSubmitActionAsync. However am getting 403 Forbidden.
The next step I tried to add the Bot to the conversation using AdaptiveCards and I get the following error "Something went wrong, please try again later." And when checking bot in channel registration I found the below issue:
The bot is not part of the conversation roster
So I created a graph connection and granted admin consent.Now when using GetUserTokenAsync after submit action I receive "Something went wrong, please try again later." (Testing connection created from portal.azure.com returns a token)
I find it a little bit weird to not able to retrieve what's already obvious. I can see the contact email and name so the 403 is absurd in my own opinion or I might be doing something wrong.
SO my question is either how to check the detailed errors that are returned or is there any easier way to retrieve members emails.
Thank you
So the problem was in the bot manifest file it seems that I didn't add the below to the json:
"validDomains": [
"token.botframework.com",
"*.ngrok.io"
]

Post message to MS Teams channel using Graph API

I'm trying to send a message to MS Teams using Graph API. I'm passing access token (AAD token) with it but still, it's giving me below error. I have given all the required permissions in Azure API permissions.
error:
{
"error": {
"code": "UnknownError",
"message": "",
"innerError": {
"request-id": "53a5aaff-3d39-42ce-bdc6-74d02a756be2",
"date": "2019-12-23T06:42:27"
}
}
}
API: https://graph.microsoft.com/beta/teams/{group-id-for-Teams}/channels/{channel-id}/messages/{message-id}/replies
Oh, if this is from a bot (not clear from the original question, but clarified in your later comment) then you don't need to use the Graph API at all - there's another way to send the message using the Bot Framework tools instead. You can do this either from within your bot, or from a different application altogether. I've got a few bots where the user schedules something, like when they want a message sent, where the bot saves it to a database and I have another application (mostly I use Azure Functions right now) to send the item on that schedule.
There are some important pieces of information you need to store though, which you can get any time the users sends your bot a message - it's the information you need to store so that you know how to connect directly to that user and that conversation. It's called Pro-active Messaging, and to see how to do this, see the answer I posted at Programmtically sending a message to a bot in Microsoft Teams
If you DON'T have any conversation history with the user ever (as in they have never spoken with your bot before, and you're trying to send the first message) then it gets more complicated... Let me know if that's the case though.
Sending message to a channel using graph api is a protected api and it needs access permission from Microsoft.
Access can be requested from Microsoft access reuqest form.
Once access is given from Microsoft add graph api in api permissions of your web app, and bingo you can get the response.

Resources