So I used an account and message my skype bot.
I get this json response on my endpoint url. I sent a text "add"
{"text":"add"
,"type":"message"
,"timestamp":"2017-01-13T15:38:32.242Z"
,"id":"1234567"
,"channelId":"skype"
,"serviceUrl":"https:\/\/smba.trafficmanager.net\/apis\/"
,"from":{"id":"29:yyyy","name":"Real Person"}
,"conversation":{"id":"29:yyyy"}
,"recipient":{"id":"28:xxxx","name":"Skype Test"}
}
When I return a reponse to this url using yyyy as conversationId
POST /v3/directline/conversations/{conversationId}/activities
https://directline.botframework.com/v3/directline/conversations/yyyy/activities
with this parameter:
{
"type": "message",
"text": "registration",
"from": {
"id":"xxxx","name":"Skype Test"
},
"recipient": {"id":"yyyy","name":"Real Person"}
}
I get an unknown conversation response. Not sure what is wrong.
Your Response should look like:
{
"type": "message",
"from": {
"id": "recipient_id",
"name": "recipient_name"
},
"conversation": {
"id": "conversation_id",
"name": "conversation_name(if available)"
},
"recipient": {
"id": "from_id",
"name": "from_name"
},
"text": "response_text",
"replyToId": "activity_id"
}
Hope that Help :)
Related
When someone add my bot to their group chat in the activity object of conversationUpdate event I am not receiving the name of the group chat.
{
"membersAdded": [
{
"id": "28:306a0c33-333-47ce-a9f8-03799e676dc2"
}
],
"type": "conversationUpdate",
"timestamp": "2020-05-14T19:55:28.0039315Z",
"id": "f:9476c223-fd49-7a31-06b9-d97ff3fd4d76",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/in/",
"from": {
"id": "29:1q1sbfe3sRPvYJgi-PwHztKmrnLj7ozY233ciqF2CRitV0cOgY5ldNxWtJMDVMmXYuItSHM5xETWmlyuZvoEGXg",
"aadObjectId": "d1ac8255-7079-4bff-bda6-1593f42e7d52"
},
"conversation": {
"isGroup": true,
"conversationType": "groupChat",
"tenantId": "86b9a961-9303-4cc1-b78d-62d07f6ab178",
"id": "19:29da1fbb91314556a8bba82eaf17ea61#thread.v2"
},
"recipient": {
"id": "28:306a0c33-333-47ce-a9f8-03799e676dc2",
"name": "testbot"
},
"channelData": {
"tenant": {
"id": "86b9a961-9303-4cc1-b78d-62d07f6ab178"
}
}
}
is there any way I can get the name of the groupChat ?
#Nikhil, You do not get the Team name in member added event.Team name will be passed only in case of team rename event. Please check the documentation for more details.
I am following this sample to implement Microsoft Graph interaction. I have managed to follow and display a page with my verification code, but the Teams SDK doesn't seem to want to post the code to my bot automatically.
I have the following lines in my oauth success page, as per the sample
<script src="https://unpkg.com/#microsoft/teams-js#1.4.2/dist/MicrosoftTeams.min.js" integrity="sha384-DcoNUuQTjpW5Sw3msonn/2ojgtNvtC5fCGd5U9RUpL3g1hla1LzHz8I9YIYSXe6q" crossorigin="anonymous"></script>
<script type="text/javascript">
setTimeout(function () {
document.getElementById("instructionText").style.display = "initial";
}, 5000);
microsoftTeams.initialize();
microsoftTeams.authentication.notifySuccess("{{verificationCode}}");
</script>
According to the sample, the bot receives an invoke message with name = signin/verifyState, but I do not. The sign-in page does close though.
Any ideas on why the page will not notify my bot of the code automatically?
Sorry this took so long. Got it.
So, the issue is that you're looking for a message activity, but Teams is sending an invoke activity, which isn't caught in onMessage. Instead, in your BotController, use something like:
this.onUnrecognizedActivityType(async (turnContext, next) => {
console.log(`GOT : ${ JSON.stringify(turnContext.activity, null, 2)}`)
});
This produces:
GOT : {
"name": "signin/verifyState",
"type": "invoke",
"timestamp": "2019-06-07T22:19:53.810Z",
"localTimestamp": "2019-06-07T22:19:53.810Z",
"id": "f:490708197841asdfasdfasdf15",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer/",
"from": {
"id": "29:1AvIMwjQc1iBRcFYBe-0opf4YzVU130fNasdjkhfkldjshfjkahgsdfjklasdkjfasdfcS_7MO9DKFFNL6Ow",
"name": "asdfasdfasdfasdf",
"aadObjectId": "asdfasdfasdfasdf"
},
"conversation": {
"conversationType": "personal",
"tenantId": "asdfasdfasdfasdfasd",
"id": "asdfasdfasdfasdf"
},
"recipient": {
"id": "asdfasdfasdfasdf",
"name": "asdfasdfasdfasdf"
},
"entities": [
{
"locale": "en-US",
"country": "US",
"platform": "Windows",
"type": "clientInfo"
}
],
"channelData": {
"tenant": {
"id": "asdfasdfadsfasdf"
},
"source": {
"name": "message"
}
},
"value": {
"state": "asdfasdfasdfasdf"
},
"locale": "en-US"
}
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 sending below response to the service url provided by botFramework request https://telegram.botframework.com/v3/conversations/-263387177/activities/
My intent is that using sendMessage method of telegram I am able to route a text to the telegram channel via microsoft botframework
The http post which I am sending is as below
{
"type": "message",
"locale": "en-Us",
"chat_id":-263387177,
"channelID":"telegram",
"from": {
"id": "GTSFIBot",
"name": "sapeops"
},
"text":"hi , Greetings!",
"replyToId": "1505813737353",
"recipient": {
"id": "DirectLineClient"
},
"conversation": {
"isGroup": true,
"id": "-263387177",
"name": "sapeops group"
},
"channelData": {
"method": "sendMessage",
"parameters": {
"chat_id": -263387177,
"parse_mode": "HTML",
"text": "<B>Greetings! How are you doing?</B>"
},
"chat": {
"id": -263387177,
"title": "sapeops group",
"type": "group",
"all_members_are_administrators": true
}
}
}
I get 502 bad gateway response and a below JSON.
{
"error": {
"code": "ServiceError",
"message": "Telegram API returned a result code indicating non-success"
}
}
When I post a message to my Microsoft bot using Postman, the message is sent to my Skype. When I post the message to Telegram channel, I get error message 400 Bad Request (The request cannot be fulfilled due to bad syntax. The following is post body.
{
"type": "message",
"locale": "en-Us",
"channelID":"telegram",
"from": {
"id": "28:01a4752e-6cb0-459f-b94f-.....",
"name": "bot"
},
"recipient": {
"id": "29:1rNJPaNGCMPithEDVjoN00SU5S6fG......",
"name": "My name"
},
"conversation": {
"id": "29:1rNJPaNGCMPithEDVjoN00SU5S6fGZ"
},
"channelData":
{
"method": "sendMessage",
"parameters":
{
"text": "This message is HTMLformatted.",
"parse_mode": "HTML"
}
}
}