How do I get notifySuccess to send verification code? - botframework

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"
}

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.

not receiving name of the group in activity object of groupChat conversation update. MSBot framework for Teams (nodejs)

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.

Google Knowledge Graph API `articleBody` field missing from `detailedDescription`

Following the sample request for Taylor Swift shown here, I get the following response which does not match the response shown on the site. Moreover, I'm interested in the articleBody of the detailedDescription field which is not being returned the same way. Has there been an update to the API that was not reflected in the documentation? Is there a way to request the articleBody via the Python API?
{
"#context": {
"#vocab": "http://schema.org/",
"goog": "http://schema.googleapis.com/",
"EntitySearchResult": "goog:EntitySearchResult",
"detailedDescription": "goog:detailedDescription",
"resultScore": "goog:resultScore",
"kg": "http://g.co/kg"
},
"#type": "ItemList",
"itemListElement": [
{
"#type": "EntitySearchResult",
"result": {
"#id": "kg:/m/0dl567",
"name": "Taylor Swift",
"#type": [
"Thing",
"Person"
],
"description": "American singer",
"image": {
"contentUrl": "http://t0.gstatic.com/images?q=tbn:ANd9GcST848UJ0u31E6aoQfb2nnKZFyad7rwNF0ZLOCACGpu4jnboEzV",
"url": "https://en.wikipedia.org/wiki/Begin_Again_(Taylor_Swift_song)"
},
"url": "http://taylorswift.com/"
},
"resultScore": 1237.141968
}
]
}

Why my Alexa ReportStatus directive response not working?

I want to enable alexa voice control for my smart home device. I was able to discover device. Now all devices are showing in alexa app. But when I try to turn on the device from my alexa app it is getting stuck. Loader is moving unlimited period of time. It is actually calling ReportStatus directive.
This is the json that I am getting from alexa app for a light. The light has only turn on and turn off capabilities.
{
"directive": {
"endpoint": {
"cookie": {
"detail1": "For simplicity, this is the only appliance",
"detail2": "that has some values in the additionalApplianceDetails"
},
"endpointId": "endpoint-001",
"scope": {
"token": "weza|IwEBIGu_tmpSTQaEPvhm0OYy-4ncjve_Au1788TAWR2DC8b7xJlPDiX3HV3rJUtG0qyauIlman4bX4ZCK0-6NvKWagqXNLSdH3bDBLxD_9VtgCQo6wUlEd4DNmL9Yf5sWuUCkV1ALAxxbhqPs3QlTofubxtpSnF05ZWOSjyNUlM3ShryLh7owTywFa_7oXCCaLdLCTiqOm27aPn-yyJEDNG57Sc9iysrZkJHaxVPbdZdcqRmaw9zFGVWOqsgjqiojkKrfztslVL1Ggo6v7Teg8isrZD8osr5HFkWAmZHi8K7UrHmwQnsD9CosgSxSG0avnUoomdsZx3_LPjLJKf5twJrN1vbLolzOgxUbVuAVPVrs8UN40KFEu6eCv_7rYz9AER_61di-4w1K27kjeJvzPMIKlLXLvv6Z-2GyuQq_8M1fUdM0SgiAkqjf92S9SNxezTUiDYdOjB1JrktbQc0WM6OYYXOMjtXcCPx3bqNwWoPZWBk7qptLTurCHcYnnDl27Q0RcJ3u1vFvMaT8l0x87K6wqW2",
"type": "BearerToken"
}
},
"header": {
"correlationToken": "AAAAAAQAeXUb9VLQcUVXClbXZQBvIDAIAAAAAAAAiBMdYahxBjRIHYbFACdRe+68uyc0KiCkClvpOCfh5dZw7NlTHoqnbbjPPydl4Nmkh4KLuFtKboYiwENwsVa9Q2WwAgRlEM+SR9PSNrWqnKvKDtulnkVXuTDkHf8f4LskbFd4VhX6cN518TA0MaZZvSfli9CN7KNY7m07P+eIv71nwxUFP5UN4xe4Jsz1V6nLzUGAG2jJIW4Lg0ARHENqDhbFtra4SV+vPXUN8L4qIwvC5xD6/mjsdN7B1ihGy/8djQA2+cxZ3XOEz2UOATyPEDlpVw5PBasQiJbRiSFSZZqEvQ0NHNfPWAWz5ieQXO1z1NAE5RMgn9d5gcEfDecjScP9DE2Yw43MypX/3VMDJmbjuTlhg9AabxLTQndKV8w9JNM1lLXcdp7i2JShOLO0bDDBPqJH1zsiZGJ93zWn+VDOTzDt+482V/AWgcHOWYnB+UZnL9GZFwEKVWTcQ20u2inFK9J11M5wr3ia57WDP6SQ7zkAmERDGfL0wswN/j0vFpqw+0/G7vjAUs2hGyg9oOy7fN2PFntk6IHV8mh47sC+ENj9dujJ9+ENwfEwEi792m7WlA8PGtvxdEqyVib5hY3qfNirqPMhMmPBf2hZlpbUfpf69q9R8GNFq41EZnTlg/AxSBjjLUJazaKQ8RU1VgipcdK1aGupJf5Oi85uEuYWN96OoEtivhUTZXg==",
"messageId": "dd8670d5-3afa-483a-93a3-f0fff0ab6572",
"name": "ReportState",
"namespace": "Alexa",
"payloadVersion": "3"
},
"payload": {}
}
}
This is the response I am sending from lambda function. It is written in python 3.6.
{
"event": {
"context": {
"properties": [
{
"name": "powerState",
"namespace": "Alexa.PowerController",
"timeOfSample": "2018-12-17T18:17:35.00Z",
"uncertaintyInMilliseconds": 500,
"value": "ON"
}
]
},
"endpoint": {
"cookie": {
"detail1": "For simplicity, this is the only appliance",
"detail2": "that has some values in the additionalApplianceDetails"
},
"endpointId": "endpoint-001",
"scope": {
"token": "weza|IwEBIGu_tmpSTQaEPvhm0OYy-4ncjve_Au1788TAWR2DC8b7xJlPDiX3HV3rJUtG0qyauIlman4bX4ZCK0-6NvKWagqXNLSdH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9+ENwfEwEi792m7WlA8PGtvxdEqyVib5hY3qfNirqPMhMmPBf2hZlpbUfpf69q9R8GNFq41EZnTlg/AxSBjjLUJazaKQ8RU1VgipcdK1aGupJf5Oi85uEuYWN96OoEtivhUTZXg==",
"messageId": "dd8670d5-3afa-483a-93a3-f0fff0ab6572",
"name": "StateReport",
"namespace": "Alexa",
"payloadVersion": "3"
},
"payload": {}
}
}
Please help me. I am stuck in this for last 2 days.
Not sure if this is related to your problem. In your response, the context element is inside event. But according to the documentation and code sample, context and event should be at the same level.
{
"context": {
"properties": [...]
},
"event": {
"header": ...,
"endpoint": ...,
"payload": {}
}
}

Skype Bot Rest API Conversation ID

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

Resources