我使用JavaScript和Botbuilder创建了一个BotFramework机器人。
对于这个机器人,我使用一个自适应对话框。在对话框的某个时候,我需要发送一个HTTP请求。
现在,我的HTTP请求步骤如下所示:
new HttpRequest().configure({
resultProperty: new StringExpression("user.teamProfile.accessToken"),
url: new StringExpression('https://login.microsoftonline.com/myTenantId/oauth2/v2.0/token'),
method: HttpMethod.POST,
contentType: new StringExpression('application/x-www-form-urlencoded'),
headers: {
"Content-Type": new StringExpression("application/x-www-form-urlencoded")
},
body: new StringExpression("client_id: myClientId, scope: https://graph.microsoft.com/.default, client_secret: myclientSecret, grant_type: client_credentials"),
responseType: ResponsesTypes.Json
})bot本身正在工作,但当它尝试执行HTTP步骤时,我得到以下错误消息:
Error: TypeError: path.indexOf is not a function不幸的是,我没有得到更多的信息。有人能帮我吗?
诚挚的问候,
BufferOverflow
发布于 2020-10-06 14:13:38
由于HttpRequest-步骤不起作用,我更改为CodeAction。
在这个CodeAction中,我执行Http请求并处理结果(转换结果或将它们保存在对话框变量中)。
代码片段可能如下所示:
new CodeAction(async (dc, options) => {
// Send your request
// options being the headers, body, etc.
const response = await this.fetch(url, options);
// Work on you result and if necessary, save it to a dialog variable
dc.state.setValue("user.yourPropertyName", value);
// Needed for the Bot to continue working
return await dc.endDialog();
})https://stackoverflow.com/questions/64116766
复制相似问题