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
Related
I'm doing a HttpPost from a message card with some user input fields. The message card is sent to MS teams and contains a Http Post action to another target which receives the user's selected inputs. I'm sending User's data in body of the Http Post. Input value substitution works fine in MS teams desktop but not working in MS teams android. Any suggestions are highly appreciated.
Snippet with httpPost:
{
"#type": "ActionCard",
"actions": [
{
"#type": "HttpPOST",
"body": "{\"Comment\":\"{{Comment.value}}\",\"Choice1\" : \"{{1c.value}}\",\"Choice2\" : \"{{2c.value}}\"}",
"name": "Submit Edit",
"target": "https://.."
}
],
"inputs": [
{
"#type": "TextInput",
"id": "Comment",
"isMultiline": true,
"isRequired": true,
"title": "Comment"
},
{
"#type": "TextInput",
"id": "1c",
"title": "Choice 1"
},
{
"#type": "TextInput",
"id": "2c",
"title": "Choice 2"
}
],
"name": "Edit"
}
]
}
Body received from MS teams android:
"body": {
"Comment": "{{Comment.value}}",
"Choice1": "{{1c.value}}",
"Choice2": "{{2c.value}}"
}
Body received from MS teams desktop:
"body": {
"Comment": "Test",
"Choice1": "Myinput",
"Choice2": "Myinput"
}
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
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.)
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.).
I am trying to use the Trello service hook with Team Foundation Server. I have followed this tutorial and the connection worked without problems but, I can't get the informations I need from the Event JSON:
The Description I Tried
This is the Event JSON:
{
"id": "03c164c2-8912-4d5e-8009-3707d5f83734",
"eventType": "git.push",
"publisherId": "tfs",
"scope": 0,
"message": {
"text": "Jamal Hartnett pushed updates to Fabrikam-Fiber-Git:master.",
"html": "Jamal Hartnett pushed updates to Fabrikam-Fiber-Git:master.",
"markdown": "Jamal Hartnett pushed updates to `Fabrikam-Fiber-Git`:`master`."
},
"detailedMessage": {
"text": "Jamal Hartnett pushed a commit to Fabrikam-Fiber-Git:master.\n - Fixed bug in web.config file 33b55f7c",
"html": "Jamal Hartnett pushed a commit to Fabrikam-Fiber-Git:master.\n<ul>\n<li>Fixed bug in web.config file 33b55f7c\n</ul>",
"markdown": "Jamal Hartnett pushed a commit to [Fabrikam-Fiber-Git](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/):[master](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/#version=GBmaster).\n* Fixed bug in web.config file [33b55f7c](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/commit/33b55f7cb7e7e245323987634f960cf4a6e6bc74)"
},
"resource": {
"commits": [
{
"commitId": "33b55f7cb7e7e245323987634f960cf4a6e6bc74",
"author": {
"name": "Jamal Hartnett",
"email": "fabrikamfiber4#hotmail.com",
"date": "2015-02-25T19:01:00Z"
},
"committer": {
"name": "Jamal Hartnett",
"email": "fabrikamfiber4#hotmail.com",
"date": "2015-02-25T19:01:00Z"
},
"comment": "Fixed bug in web.config file",
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/commit/33b55f7cb7e7e245323987634f960cf4a6e6bc74"
}
],
"refUpdates": [
{
"name": "refs/heads/master",
"oldObjectId": "aad331d8d3b131fa9ae03cf5e53965b51942618a",
"newObjectId": "33b55f7cb7e7e245323987634f960cf4a6e6bc74"
}
],
"repository": {
"id": "278d5cd2-584d-4b63-824a-2ba458937249",
"name": "Fabrikam-Fiber-Git",
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249",
"project": {
"id": "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
"name": "Fabrikam-Fiber-Git",
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/projects/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
"state": "wellFormed",
"visibility": "unchanged"
},
"defaultBranch": "refs/heads/master",
"remoteUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git"
},
"pushedBy": {
"id": "00067FFED5C7AF52#Live.com",
"displayName": "Jamal Hartnett",
"uniqueName": "Windows Live ID\\fabrikamfiber4#hotmail.com"
},
"pushId": 14,
"date": "2014-05-02T19:17:13.3309587Z",
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/pushes/14"
},
"resourceVersion": "1.0",
"resourceContainers": {
"collection": {
"id": "c12d0eb8-e382-443b-9f9c-c52cba5014c2"
},
"account": {
"id": "f844ec47-a9db-4511-8281-8b63f4eaf94e"
},
"project": {
"id": "be9b3917-87e6-42a4-a549-2bc06a7a878f"
}
},
"createdDate": "2017-07-21T16:48:44.312Z"
}
This is the Request that was send to Trello:
Method: POST
URI: https://api.trello.com/1/cards?key=7d6630fd03ac2b6fc9fde2f2ef0c4096&token=********
HTTP Version: 1.1
Headers:
{
Content-Type: application/json; charset=utf-8
}
Content:
{
"name": "Test NÂș ",
"desc": "Description: ",
"pos": "top",
"due": null,
"labels": "green",
"idList": "5935a0d45ff8e5a6c8f828b9"
}
The only field that I could get/read from the Event JSON was the "message".
What am I doing wrong?
If you want to get the push ID and comments, the description is:
{{push.pushId}}
{{push.commits[0].comment}}
Update
Eddie is right you should use push as the resource in this case. The docs are not so clear. In the end, it was something so simple. However the corresponding checkin is not work for Code checked in event.
The docs could definitely be more clear in how the resource are for each event which applied to help avoid this confusion.
The basic form of the placeholder is {{resource.field}} where
resource is the name of the resource raising the event (workitem, build, etc) and field is a field within the resource section of the
event, like id. So, if the subscription were for a completed build,
it might be something like:
Build {{build.id}} completed at {{build.finishTime}}
Seems the issue is you are using the wrong placeholder in this case. According to your send Request , resource.pushID & resource.commits.[0].comment is not replaced by values from the event that was raised.