如何让notifySuccess发送验证码?
How do I get notifySuccess to send verification code?
我正在关注 this sample 以实现 Microsoft Graph 交互。我已设法关注并显示带有我的验证码的页面,但 Teams SDK 似乎不想 post 自动向我的机器人发送验证码。
根据示例,我的 oauth 成功页面中有以下几行
<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>
根据示例,机器人收到了一条名称为 signin/verifyState 的调用消息,但我没有。不过登录页面确实关闭了。
关于为什么页面不会自动将代码通知我的机器人的任何想法?
抱歉,这花了这么长时间。知道了。
因此,问题是您正在寻找 message
activity,但 Teams 正在发送 invoke
activity,但未被捕获onMessage
。相反,在您的 BotController 中,使用如下内容:
this.onUnrecognizedActivityType(async (turnContext, next) => {
console.log(`GOT : ${ JSON.stringify(turnContext.activity, null, 2)}`)
});
这会产生:
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"
}
我正在关注 this sample 以实现 Microsoft Graph 交互。我已设法关注并显示带有我的验证码的页面,但 Teams SDK 似乎不想 post 自动向我的机器人发送验证码。
根据示例,我的 oauth 成功页面中有以下几行
<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>
根据示例,机器人收到了一条名称为 signin/verifyState 的调用消息,但我没有。不过登录页面确实关闭了。
关于为什么页面不会自动将代码通知我的机器人的任何想法?
抱歉,这花了这么长时间。知道了。
因此,问题是您正在寻找 message
activity,但 Teams 正在发送 invoke
activity,但未被捕获onMessage
。相反,在您的 BotController 中,使用如下内容:
this.onUnrecognizedActivityType(async (turnContext, next) => {
console.log(`GOT : ${ JSON.stringify(turnContext.activity, null, 2)}`)
});
这会产生:
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"
}