Unable to hit url by HttpPOST in actionable cards in microsoft teams - microsoft-teams

I am trying to make a Actionable Message for Microsoft Teams with an ActionCard.
I want to hit a url by HttpPost. When I hit the url, I got the error message:
Failed to send
There was a problem submitting your changes. Try again in a minute.
I followed Microsoft's documentation and according to the documentation my code is right. I am very confuse why this error is coming up.
This is the ActionCard I'm using:
{
"#type": "ActionCard",
"name": "Selector",
"inputs": [{
"#type": "MultichoiceInput",
"id": "list",
"title": "Select a status",
"isMultiSelect": "false",
"style": "expanded",
"choices": [{
"display": "In Progress",
"value": "1"
},
{
"display": "Active",
"value": "2"
},
{
"display": "Closed",
"value": "3"
}
]
}],
"actions": [{
"#type": "HttpPOST",
"name": "Save",
"body": "value={{list.value}}",
"target": "https://www.google.com"
}]
}

Microsoft Teams is surfacing an error because you're call resulted in an error.
Your code looks fine but your target URL (Google.com) isn't valid. You can't make an POST request to https://www.google.com. Attempting to do so results in a Error 405 (Method Not Allowed).
Making an HttpPOST requires a target that is willing to accept it and return some type of 2xx Success response. Typically it will be 200 OK but some APIs get more granular with their responses (201 Created, 202 Accepted, etc.).

Related

Call Microsoft Graph API from Actionable Message

I'm trying to send an email using Microsoft Graph API from an action in an actionable message. (So send an email from a button in an email) However I'm always receiving a 401 Error. I tested the graph API in normal setting and the Auth token is valid, but here it seems to work differently.
Is it possible at all to achieve this?
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "ActionSet",
"id": "f8d6ddb5-ed34-e8e4-59ec-73084e885bbb",
"actions": [
{
"type": "Action.Http",
"id": "6a807e29-1023-ed90-713a-94209c847c7b",
"title": "Envoyer",
"url": "https://graph.microsoft.com/v1.0/me/sendMail",
"style": "positive",
"isPrimary": true,
"method": "POST",
"headers": [
{
"name": "Authorization",
"value": "Bearer ..."
},
{
"name": "Content-Type",
"value": "application/json"
}
],
"body": "..."
}
]
}
],
"padding": "None",
"#type": "AdaptiveCard",
"#context": "http://schema.org/extensions"
}
(Edit)
This is how I get the token:
Providers.globalProvider = new TeamsProvider ({
clientId: {my client id},
authPopupUrl: '/auth.html'
});
const token = await Providers.globalProvider.getAccessToken({scopes: ['Mail.Send', 'Mail.ReadWrite']});
Regardless of how you generate the Adaptive Card, you cannot use the Microsoft Graph API from the context of Outlook using Outlook Actionable Messages :
https://github.com/microsoft/AdaptiveCards/issues/5674
Currently teams does not support http card action. Please go through this documentation for supported card actions.

Microsoft Teams Connector: HttpPOST on MessageCard returns ODataContentTypeException

We set up a new Microsoft Teams Connector and successfully set the settings to POST cards to the received WebhookUrl.
In the body that we send, we included the option to make HttpPost requests to a defined target URL (using ngrok.io tunnel for development). You can see the sent messageCard below:
{
"#type": "MessageCard",
"#context": "https://schema.org/extensions",
"summary": "Card \"Test card\"",
"themeColor": "0078D7",
"title": "Card created: \"Just another test\"",
"potentialAction": [
{
"#type": "ActionCard",
"name": "Add a comment",
"inputs": [
{
"#type": "TextInput",
"id": "comment",
"isMultiline": true,
"title": "Enter your comment"
}
],
"actions": [
{
"#type": "HttpPOST",
"name": "Ok",
"target": "https://dd846f80.ngrok.io/teamshooks/actions",
"body": "{\"Comment\":\"This is a test\"}",
"headers": [
{
"Content-Type": "application/json"
},
{
"aw-teamid": "00000000-0000-0000-0000-000000000001"
}
]
}
]
}
]
}
The card is displayed correctly in the channel in Microsoft Teams.
When a user clicks on this button, to make a HttpPOST to the specified url, we never receive the request on our side but can see that Microsoft returns the following response to the internal "executeAction" request:
The request was sent on: Fri, 13 Dec 2019 11:09:48 GMT
{
"status": "Failed",
"actionId": "c520b20a-3e04-4e21-b4fd-c3a2f760c533",
"properties":
{
"displayMessage": "<p>Could not complete the requested action. Please try again later.</p>\n",
"errorCode": "ODataContentTypeException"
}
}
The following settings are set-up in the Connectors Developer Dashboard (and in the manifest.json):
"connectors": [
{
"connectorId": "6b2ba9c0-7c0a-4524-9e6d-64f061350aa4",
"scopes": [
"team"
],
"configurationUrl": "https://dd846f80.ngrok.io/msteams/aworkConnector/config.html"
}
]
"validDomains": [
"dd846f80.ngrok.io"
]
Do you want to enable actions on your Connector cards? - Yes
Actions Url: https://dd846f80.ngrok.io/teamshooks/actions
Is there anything we are currently doing wrong or does anyone have an idea on how to solve the returned ODataContentTypeException? We need to receive the request in our backend, in order to integrate Micorsoft Teams into our software.
Upload the manifest.json from an admin account, and add the ngrok url in the valid domains. Microsoft teams have blocked custom connectors from performing actions when uploaded by non admin users

Make POST call with HttpPOST Action form Teams message

I have a MessageCard which I am sending to my Teams channel via the Incoming Webhook connector. This is working well. However, the card has the button with HttpPOST Action. In "target" I defined URL to my API in the format: "http://user:pass#address/resource/action.html?add2Queue=test". When I am trying to push button I am getting the error: "Target URL scheme 'http://user:pass#address/resource/action.html?add2Queue=test' is not allowed.". I didn't find any restrictions for using HTTP. I am using the "Incoming Webhook" connector.
Is it works with HTTP or only HTTPS?
JSON:
{
"#type": "MessageCard",
"#context": "http://schema.org/extensions",
"themeColor": "0076D7",
"summary": "Action on environments status change",
"sections": [{
"activityTitle": "Envrionments status are going to change",
"facts": [{
"name": "Environment:",
"value": "3"
}, {
"name": "Due date",
"value": "On Friday 8:00 PM Central Time"
}, {
"name": "Pending Action",
"value": "Environment are going to be stopped"
}, {
"name": "Notes",
"value": "You can pause this action by pressing Pause button bellow"
}],
"markdown": true
}],
"potentialAction": [{
"#type": "HttpPOST",
"name": "Pause Action",
"actions": [{
"#type": "HttpPOST",
"name": "Pause",
"target": "http://user:pass#server/teamcity/httpAuth/action.html?add2Queue=Marlin_Infrastructure_MarlinInfrastructureStopStartEnvironments_TechnicalTasks_N"
}]
}]
}
Explanation of Teams sending a bearer authorization token can be found here
Based on that I did:
"#type": "HttpPOST",
"name": "Your Action",
"target": "https://www.your-url.com",
"headers": [
{
"name": "Authorization",
"value": null
}
],
"body": "{\"whateverdata\"}"
and it worked for me. Works on Teams , I imagine it should work for outlook as well

Why are my chatbot refresh cards in Teams not refreshing?

I am serving out O365 connector cards to my teams channel in my chatbot, for the user to use an HttpPost action to send data back to the bot.
Here is a sample invoke message when the user saves:
{
"name": "actionableMessage/executeAction",
"type": "invoke",
"timestamp": "2018-06-16T20:58:24.388Z",
"localTimestamp": "2018-06-16T21:58:24.388+01:00",
"id": "snip",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/emea-client-ss.msg/",
"from": {
"id": "snip",
"name": "my name",
"aadObjectId": "snip"
},
"conversation": {
"conversationType": "personal",
"id": "long conversation id"
},
"recipient": {
"id": "bot id",
"name": "bot name"
},
"entities": [
{
"locale": "en-US",
"country": "US",
"platform": "Web",
"type": "clientInfo"
}
],
"channelData": {
"tenant": {
"id": "tenant id"
},
"source": {
"name": "message"
}
},
"replyToId": "message id",
"value": {
"body": "{\"sportType\":\"1\", \"tournamentName\":\"FIFA Soccer World Cup\",\"startTime\":\"2018-06-14T03: 00: 00.000Z\", \"endTime\":\"2018-07-16T07: 30: 00.000Z\", \"timeZone\":\"Russian Standard Time\", \"tournamentId\": \"1\"}",
"actionId": "SaveTournament"
}
}
In response to a save card, I am returning an ActionCard in the response body, and I am including an HTTP header "CARD-UPDATE-IN-BODY" with a value "true". Here is a sample response message:
{
"#type": "ActionCard",
"inputs": [
{
"#type": "TextInput",
"isMultiline": true,
"maxLength": 500.0,
"id": "SaveStatus",
"isRequired": false,
"title": "Save Status",
"value": "You updated the tournament FIFA Soccer World Cup running from 6/14/2018 to 7/16/2018 in timezone Russian Standard Time"
}
],
"actions": [
{
"#type": "HttpPOST",
"body": "{\"tournamentId\": \"1\"}",
"name": "Update FIFA Soccer World Cup again",
"#id": "UpdateTournament#1"
}
],
"name": "Save Tournament",
"#id": "SaveTournament"
}
I have traced this in my web app so I know that is what is being returned to the bot framework middleware.
In my teams app in the browser,when I trace the response message with Fiddler, the card invoke response is not getting the refresh card I send, it is just getting a generic 200 response with an empty response body. Can anyone point me to a demo of refresh cards that work with Teams, or tell me what's wrong with my messages?
Teams doesn't support updating the original card by responding to the invoke message. Instead, you need to explicitly update the message by calling the Bot Framework API (see https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bot-conversations/bots-conversations#updating-messages).
The incoming invoke message has the information you need to update the original message:
<serviceurl>/v3/conversations/<conversationid>/activities/<activityid>
<serviceurl>: serviceUrl
<conversationid>: conversation.id
<activityid>: replyToId
(The details of how to update a message depends on exactly which SDK you're using, but in the end you'll need those 3 items to refer to the message.)

Mailchimp API v3 add merge field with checkboxes

I need to add checkboxes merge-field with choices to a list.
API key is valid, other requests work and I'm doing such request:
POST https://us12.api.mailchimp.com/3.0/lists/424242/merge-fields
Body: {"name": "provider_accounts", "type": "checkboxes", "options": { "choices": ["BMW", "Audi", "Toyota"]}, "tag": "provider_accounts"}
And I got an error for some reason!
{
"type": "http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
"title": "Invalid Resource",
"status": 400,
"detail": "The resource submitted could not be validated. For field-specific details, see the 'errors' array.",
"instance": "",
"errors": [
{},
{}
]
}
BTW if I change the type to radio request works and new merge-field is created.

Resources