Can't get almost all information from event from service Hook - visual-studio

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.

Related

Body always empty when answering an invoke

I have a live Microsoft Teams application with a couple of working functionalities. Right now I am working on a new feature where the user clicks on a button in a previously sent adaptive card and I will open another adaptive card with a form for the user to fill. I am using this documentation as a base, which has a really similar example as to what I am trying to achieve here.
Since I am working with an adaptive card the button that will open my form card is an Action.Submit button with "msteams": {"type': 'task/fetch"} inside its data. When I click that button I receive the correct invoke call, the body looks like this:
{
"type": "invoke",
"timestamp": "2021-02-01T20:19:34.327Z",
"localTimestamp": "2021-02-01T15:19:34.327-05:00",
"id": "f:955407977095344101",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer/",
"from": {
"id": "censured",
"name": "censured",
"aadObjectId": "censured"
},
"conversation": {
"conversationType": "personal",
"tenantId": "censured",
"id": "censured"
},
"recipient": {
"id": "censured",
"name": "Tcensured"
},
"entities": [
{
"locale": "censured",
"country": "censured",
"platform": "censured",
"timezone": "censured",
"type": "clientInfo"
}
],
"channelData": {
"tenant": {
"id": "censured"
},
"source": {
"name": "message"
},
"legacy": {
"replyToId": "censured"
}
},
"replyToId": "censured",
"value": {
"commandId": "reply_feedback",
"requested_feedback_id": 1,
"type": "composeExtension/fetchTask"
},
"locale": "censured",
"localTimezone": "censured"
}
It seems like the invoke call is correct, so the next step is to answer the call with my adaptive card. However, it doesn't matter what I answer this call with, when I inspect the invoke call in my browser the answer is always empty, even if I answer with a really simple task response like (which I got from the documentation)
{
"task": {
"type": "continue",
"value": {
"title": "Task module title",
"height": 500,
"width": "medium",
"url": "https://contoso.com/msteams/taskmodules/newcustomer",
"fallbackUrl": "https://contoso.com/msteams/taskmodules/newcustomer"
}
}
}
Or even
{
"task": {
"type": "message",
"value": "Test"
}
}
I still get an empty response on the front-end side. I am fairly confident that I am properly answering the call on my side with data, I have a lot of other features in this same application working so I don't think it is some problem where I am actually giving an empty body from my side. Maybe for the specific invoke call I need to answer things in a different manner?
Obs: I am using Python with no SDKs, so I build Adaptive Cards and interpret the requests on my application.

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

Alexa Skill: Interaction model is not being updated during test

I am developing a Alexa Skill and I have an Intent named NewAppointmentIntent which originally had 7 slots.
I have added a new Slot yesterday named Doctor and successfully built the Skill.
When I invoke that intent, it still have 7 Slots and not 8. The Doctor Slot does not appears in the request and responses outputs.
The Intent in images:
The output when invocing the Intent, where slot Doctor expected in slots attribute:
"request": {
"type": "IntentRequest",
"requestId": "amzn1.echo-api.request.9529849e-190d-4278-95a8-3702b3ee4d1c",
"timestamp": "2018-12-12T10:05:14Z",
"locale": "en-US",
"intent": {
"name": "NewAppointmentIntent",
"confirmationStatus": "NONE",
"slots": {
"Status": {
"name": "Status",
"confirmationStatus": "NONE"
},
"Comment": {
"name": "Comment",
"confirmationStatus": "NONE"
},
"ReasonForVisit": {
"name": "ReasonForVisit",
"confirmationStatus": "NONE"
},
"Time": {
"name": "Time",
"confirmationStatus": "NONE"
},
"EmergencyType": {
"name": "EmergencyType",
"confirmationStatus": "NONE"
},
"PatientNumber": {
"name": "PatientNumber",
"confirmationStatus": "NONE"
},
"Day": {
"name": "Day",
"confirmationStatus": "NONE"
}
}
},
"dialogState": "STARTED"
}
So I wish to know how to refresh the Skill?
Close the window, re-open and in your console -> Save the model -> Build the model. Then test again.
If still doesn't show, click on the JSON Editor(this will be the last option in the list of your Interaction model), then in your NewAppointmentIntent can you see the Docter slot in the slots array?
If not, then maybe something was broken when you created the slot. So delete the Docter slot and re-add it. Then again verify it in JSON editor and this should solve the problem.

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.)

MobileFirst create wrong SMS request

IBM MobileFirst Platform Foundation 8.0.0.
After configuring SMS settings I am trying to send a message but the request is created in the wrong way. See the result below.
//REST API : send notification request
{
"message": {
"alert": "Hello World from an SMS message"
},
"notificationType":3,
"target" : {
"deviceIds" : ["9a149c24-8859-3383-6067-d161e46d2554"]
}
}
The created request:
473607:[2017-01-02 16:44:02.494] - [440093822] Request received: HTTP GET /send.aspx?
encode=false&name=toParamName&value=Recipients&encode=false&name=textParamName&value=MessageText&encode=false&name=MessageType&value=text&encode=false&name=SenderName&value=PLIX&encode=false&name=UserName&value=MahmoudSamy&encode=true&name=Password&value=xyz&to=20100051111&text=Hello+World+from+an+SMS+message+2
//SMS settings
{
"port": "80",
"programName": "/sendsms",
"host": "xyz.com",
"name": "SMSGateway",
"parameters": [
{
"encode": "false",
"name": "toParamName",
"value": "to"
},
{
"encode": "false",
"name": "textParamName",
"value": "text"
},
{
"encode": "false",
"name": "SenderName",
"value": "Support"
},
{
"encode": "false",
"name": "UserName",
"value": "xyz"
},
{
"encode": "false",
"name": "Password",
"value": "xyz"
}
]
}
We tried to send SMS with SMS settings shared by you.
We are able to get correct value pair in the created request.
Below is the created request
GET /gateway/add.php?encode=false&name=toParamName&value=to&encode=false&name=textParamName&value=text&encode=false&name=SenderName&value=Support&encode=false&name=UserName&value=xyz&encode=false&name=Password&value=xyz&to=99&text=Hello+World+from+an+SMS+message HTTP/1.1
Also in created request shared by you, I am noticing different username value than given in sms settings.
Could you please tell us how you are checking the request. We are using wireshark to capture.
the below configuration works with me but it force me to accept to and text parameters.
{
"port": "80",
"programName": "/sendsms",
"host": "xyz.com",
"name": "SMSGateway",
"parameters": [{
"SenderName": "Support",
"MessageType": "text",
"UserName": "xyz",
"Password": "xyz"
}]
}
HTTP GET /send.aspx?SenderName=Support&MessageType=text&UserName=xyz&Password=xyz&to=083127312763&to=hello+world

Resources