Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Botframework 使用';证书';通过Bot框架V4上的Webchat_Botframework_Web Chat - Fatal编程技术网

Botframework 使用';证书';通过Bot框架V4上的Webchat

Botframework 使用';证书';通过Bot框架V4上的Webchat,botframework,web-chat,Botframework,Web Chat,我的机器人在使用授权令牌+区域对调用语音服务时工作正常 代码在下面被剪掉了 webSpeechPonyfillFactory=wait window.WebChat.createCognitiveServicesSpeechServicesPonyfillFactory({authorizationToken,region}) 但是,浏览器上会显示以下警告消息: botframework webchat:“authorizationToken”、“region”和“subscriptionKey

我的机器人在使用授权令牌+区域对调用语音服务时工作正常
代码在下面被剪掉了
webSpeechPonyfillFactory=wait window.WebChat.createCognitiveServicesSpeechServicesPonyfillFactory({authorizationToken,region})
但是,浏览器上会显示以下警告消息:
botframework webchat:“authorizationToken”、“region”和“subscriptionKey”已弃用,将于2020-12-17或之后删除。请改用“凭证”。

如何将身份验证代码迁移到新方法

欢迎使用代码示例。这是我使用的代码。我在本地运行一个服务器来调用返回令牌(和区域)的语音API

在Web聊天代码中,只需将返回的令牌和区域传递到
createCognitiveServicesPeechServicesPonyFillFactory()
。你的代码不需要和我的匹配,特别是。这样做就足够了:

const webSpeechPonyfillFactory = await window.WebChat.createCognitiveServicesSpeechServicesPonyfillFactory( {
  credentials: {
    authorizationToken: authorizationToken,
    region: region
  }
} );
或者,根据您构造凭据对象的方式

{凭证:凭证}


示例代码:

const path=require('path');
const restify=require('restify');
const request=require('request');
const bodyParser=require('body-parser');
const corsmidleware=require('restify-cors-middleware');
const cors=corsMiddleware({
来源:['*']
});
const ENV_FILE=path.join(_dirname,'.ENV');
require('dotenv').config({path:ENV_FILE});
//创建HTTP服务器。
const server=restify.createServer();
server.pre(cors.preflight);
服务器使用(cors.actual);
use(bodyParser.json({
扩展:false
}));
侦听(process.env.port | | process.env.port | | | 3500,函数(){
log(`\n${server.dl_name}正在侦听${server.url}.`);
});
server.post('/speechservices/token',异步(req,res)=>{
常量选项={
方法:“POST”,
uri:`https://${process.env.SPEECH\u SERVICES\u REGION}.api.cognitive.microsoft.com/sts/v1.0/issueToken`,
标题:{
“Ocp Apim订阅密钥”:process.env.SPEECH\u SERVICES\u订阅密钥
}
};
request.post(选项,(错误、响应、正文)=>{
如果(!error&&response.statusCode<300){
body={region:process.env.SPEECH\u SERVICES\u region,authorizationToken:body};
res.send({
authorizationToken:body.authorizationToken,
区域:body.region
});
log(`Someone requested a speech token…(${response.statusCode})`);
}否则如果(response.statusCode>=400&&response.statusCode<500){
res.send(response.statusCode);
}否则如果(response.statusCode>=500){
res.status(响应状态代码);
res.send('检索令牌的调用失败');
}
});
});
const getSpeechToken=async(凭证={})=>{
const response=等待获取(`http://localhost:3500/speechservices/token`, {
方法:“POST”,
} );
如果(response.status==200){
const{authorizationToken,region}=wait response.json();
凭证['authorizationToken']=authorizationToken;
凭证['region']=地区;
返回凭证;
}否则{
console.log('错误')
}
}
const webSpeechPonyfillFactory=等待窗口.WebChat.createCognitiveServicesSpeechServicesPonyfillFactory({
凭据:等待getSpeechToken()
} );
渲染(
activity.locale==='en-US'?
voices.find(({name})=>/KatjaNeural/iu.test(name))
:
voices.find(({name})=>/KatjaNeural/iu.test(name))
||voices.find(({name})=>/Apollo/iu.test(name))}
webSpeechPonyfillFactory={webSpeechPonyfillFactory}
/>
,
document.getElementById('webchat')
);

希望有帮助

接受/向上投票答案服务于更大的堆栈溢出社区和任何有类似问题的人。如果你觉得我的回答足够,请“接受”并投票表决。如果没有,让我知道我还能提供什么帮助!谢谢!将代码更改为以下实现后,警告消失:const webSpeechPonyfillFactory=wait window.WebChat.createCognitiveServicesPeechsServicesPonyfillFactory({凭据:{authorizationToken:authorizationToken,region:region});