Я пытаюсь использовать платформу бота, чтобы отправить уведомление пользователя с моей локальной загруженной вкладки «Команды»
- Я создал бота и развернул его на Azure
- Бот отлично работает спример кода, чтобы ответить любому пользователю, отправившему на него.
- Но когда я попытался использовать кнопку (я написал это для проверки отправки уведомлений) на вкладке Команды, чтобы вызвать событие, отправляющее уведомление пользователю, консольжурнал показал мне ошибки:
Failed to load https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://c78cf14b.ngrok.io' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
VM27 bundle.js:160028 ERROR: ChatConnector: startConversation - error starting conversation.
__stack_frame_overlay_proxy_console__ @ VM27 bundle.js:160028
error @ VM27 bundle.js:30562
(anonymous) @ VM27 bundle.js:23677
(anonymous) @ VM27 bundle.js:24109
(anonymous) @ VM27 bundle.js:24198
(anonymous) @ VM27 bundle.js:24166
(anonymous) @ VM27 bundle.js:24160
tryCallOne @ VM27 bundle.js:32455
(anonymous) @ VM27 bundle.js:32541
flush @ VM27 bundle.js:11479
characterData (async)
requestCall @ VM27 bundle.js:11574
rawAsap @ VM27 bundle.js:11443
handleResolved @ VM27 bundle.js:32531
handle @ VM27 bundle.js:32527
finale @ VM27 bundle.js:32593
reject @ VM27 bundle.js:32589
(anonymous) @ VM27 bundle.js:32625
(anonymous) @ VM27 bundle.js:24152
self.callback @ VM27 bundle.js:176800
./node_modules/events/events.js.EventEmitter.emit @ VM27 bundle.js:55618
./node_modules/request/request.js.Request.onRequestError @ VM27 bundle.js:177496
./node_modules/events/events.js.EventEmitter.emit @ VM27 bundle.js:55618
(anonymous) @ VM27 bundle.js:210914
Promise rejected (async)
./node_modules/stream-http/lib/request.js.ClientRequest._onFinish @ VM27 bundle.js:210908
(anonymous) @ VM27 bundle.js:210813
./node_modules/events/events.js.EventEmitter.emit @ VM27 bundle.js:55615
finishMaybe @ VM27 bundle.js:172091
afterWrite @ VM27 bundle.js:171953
afterTick @ VM27 bundle.js:133523
./node_modules/process/browser.js.Item.run @ VM27 bundle.js:133693
drainQueue @ VM27 bundle.js:133663
setTimeout (async)
runTimeout @ VM27 bundle.js:133581
./node_modules/process/browser.js.process.nextTick @ VM27 bundle.js:133683
nextTick @ VM27 bundle.js:133522
onwrite @ VM27 bundle.js:171941
WritableState.onwrite @ VM27 bundle.js:171641
./node_modules/stream-http/lib/request.js.ClientRequest._write @ VM27 bundle.js:211026
doWrite @ VM27 bundle.js:171889
writeOrBuffer @ VM27 bundle.js:171878
./node_modules/readable-stream/lib/_stream_writable.js.Writable.write @ VM27 bundle.js:171795
./node_modules/request/request.js.Request.write @ VM27 bundle.js:178115
end @ VM27 bundle.js:177164
(anonymous) @ VM27 bundle.js:177193
run @ VM27 bundle.js:198280
runIfPresent @ VM27 bundle.js:198309
onGlobalMessage @ VM27 bundle.js:198349
postMessage (async)
registerImmediate @ VM27 bundle.js:198360
setImmediate @ VM27 bundle.js:198267
./node_modules/request/request.js.Request.init @ VM27 bundle.js:177138
Request @ VM27 bundle.js:176742
request @ VM27 bundle.js:173150
refreshingToken.Promise.catch._this.refreshingToken @ VM27 bundle.js:24138
tryCallTwo @ VM27 bundle.js:32463
doResolve @ VM27 bundle.js:32618
Promise @ VM27 bundle.js:32484
./node_modules/botbuilder/lib/bots/ChatConnector.js.ChatConnector.refreshAccessToken @ VM27 bundle.js:24126
./node_modules/botbuilder/lib/bots/ChatConnector.js.ChatConnector.getAccessToken @ VM27 bundle.js:24165
./node_modules/botbuilder/lib/bots/ChatConnector.js.ChatConnector.addAccessToken @ VM27 bundle.js:24189
./node_modules/botbuilder/lib/bots/ChatConnector.js.ChatConnector.authenticatedRequest @ VM27 bundle.js:24078
./node_modules/botbuilder/lib/bots/ChatConnector.js.ChatConnector.startConversation @ VM27 bundle.js:23653
(anonymous) @ VM27 bundle.js:25581
./node_modules/botbuilder/lib/bots/UniversalBot.js.UniversalBot.tryCatch @ VM27 bundle.js:25654
./node_modules/botbuilder/lib/bots/UniversalBot.js.UniversalBot.ensureConversation @ VM27 bundle.js:25575
async.eachLimit.errorLogger._this.tryCatch.channelId @ VM27 bundle.js:25340
(anonymous) @ VM27 bundle.js:31303
replenish @ VM27 bundle.js:31441
(anonymous) @ VM27 bundle.js:31452
./node_modules/botbuilder/node_modules/async/lib/async.js.async.forEachLimit.async.eachLimit @ VM27 bundle.js:31342
./node_modules/botbuilder/lib/bots/UniversalBot.js.UniversalBot.send @ VM27 bundle.js:25339
HomePage.buttonClicked @ VM27 bundle.js:220799
BaseButton._this._onClick @ VM27 bundle.js:99242
callCallback @ VM27 bundle.js:138209
invokeGuardedCallbackDev @ VM27 bundle.js:138259
invokeGuardedCallback @ VM27 bundle.js:138316
invokeGuardedCallbackAndCatchFirstError @ VM27 bundle.js:138330
executeDispatch @ VM27 bundle.js:138621
executeDispatchesInOrder @ VM27 bundle.js:138643
executeDispatchesAndRelease @ VM27 bundle.js:138740
executeDispatchesAndReleaseTopLevel @ VM27 bundle.js:138748
forEachAccumulated @ VM27 bundle.js:138722
runEventsInBatch @ VM27 bundle.js:138876
runExtractedEventsInBatch @ VM27 bundle.js:138884
handleTopLevel @ VM27 bundle.js:142880
batchedUpdates$1 @ VM27 bundle.js:156992
batchedUpdates @ VM27 bundle.js:140210
dispatchEvent @ VM27 bundle.js:142959
interactiveUpdates$1 @ VM27 bundle.js:157047
interactiveUpdates @ VM27 bundle.js:140229
dispatchInteractiveEvent @ VM27 bundle.js:142936
VM27 bundle.js:160028 TypeError: Failed to fetch
фрагмент кода:
private buttonClicked = () => {
const address =
{
channelId: 'msteams',
user: { id: '{myUserId}' },
channelData: {
tenant: {
id: '{myTenantId}'
}
},
notification: {
alert: true
},
bot:
{
id: '{mybotid}',
name: 'Test Bot'
},
serviceUrl: 'https://smba.trafficmanager.net/amer/'
}
const connector = new builder.ChatConnector({
appId: process.env.MicrosoftAppId,
appPassword: process.env.MicrosoftAppPassword,
});
const bot = new builder.UniversalBot(connector);
const msg = new builder.Message().address(address);
msg.text('Hello, this is a notification');
msg.summary('This is a summary');
bot.send(msg);
}
Похоже, мне нужно настроить токен на предъявителя: https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference?view=azure-bot-service-4.0#get-conversation-members
Но какя должен настроить это при отправке сообщения?
Любая помощь приветствуется!