direct-line-botframework 相关问题

Direct Line API是微软Bot框架的一部分,是Facebook,Skype等可用的消息传递渠道之一。它允许从任何自定义应用程序或网页访问使用该框架创建的机器人。

Bot框架将值传递给bot…如何在Bot C#代码中接收它们

我正在从直线Web通道传递令牌和用户ID。我想知道如何在Bot端接收这些值,以显示从直接渠道传递的用户ID或电子邮件。

回答 1 投票 0

AWS Lambda未收到行机器人帖子消息

我是Line-bot的新手,我已成功将我的AWS Lambda API网关连接到我的Line Developer平台Webhook。我知道链接是成功的,因为每次我单击行中的验证...

回答 1 投票 1

如何在Azure bot的输出活动中设置语音字段?

在Cognitive-Services-Direct-Line-Speech-Client文档中,他们提到“如果在bot的输出活动中设置了Speak字段,则您只会听到bot的语音响应。”但是...

回答 1 投票 1

不从机器人仿真器获取数据到Blob存储吗?

我有一个使用c#在框架v4中制作的机器人。我想将我的机器人中的对话保存到Blob存储中。我已经创建了一个容器来存储天蓝色。我对...

回答 1 投票 0

生成直线令牌的问题

[当我尝试根据Microsoft文档获得直接令牌时。 Postman中显示的错误。 {“ error”:{“ code”:“ BadArgument”,“ message”:“缺少令牌或机密”}} ...

回答 1 投票 0

Microsoft BOT Framework BOT间歇性停止工作

我在BOT中面临间歇性问题。我有两个使用c#和BOT Framework V4编写的机器人,它们都是相同的,并托管在IIS上。我还托管了两个WebChat Node.js应用程序...

回答 1 投票 0

Azure 机器人服务的 Directline 没有响应并被 CORS 策略阻止

我使用了 Microsoft Sample for Bot Services 中的 Bot Services 示例。 我调试后,网页没有显示任何东西。 这里有我的源代码: 我使用了 Microsoft Sample for Bot Services 中的 Bot Services 示例。 我调试后,网页没有显示任何东西。 这里有我的源代码: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Web Chat: Minimal bundle with Markdown</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <script src="https://cdn.botframework.com/botframework-webchat/latest/webchat-minimal.js"></script> <style> html, body { height: 100%; } body { margin: 0; } #webchat { height: 100%; width: 100%; } </style> </head> <body> <div id="webchat" role="main"></div> <script> (async function() { const res = await fetch('https://csharpbotdw.azurewebsites.net/directline/token', { method: 'POST' }); const { token } = await res.json(); const markdownIt = window.markdownit(); window.WebChat.renderWebChat( { directLine: window.WebChat.createDirectLine({ token }) }, document.getElementById('webchat') ); document.querySelector('#webchat > *').focus(); })().catch(err => console.error(err)); </script> </body> </html> 我只看到错误提及 Access to fetch at 'https://csharpbotdw.azurewebsites.net/directline/token' from origin 'http://localhost:63191' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. [http://localhost:63191/Test13122019] 显然,您的 Azure 应用服务没有在托管代码的 Azure 应用服务的 CORS 设置中正确配置 CORS。我在这里用详细的步骤解决了类似的问题,请尝试看看它是否对您有帮助。 似乎 URL 有问题:https://csharpbotdw.azurewebsites.net/directline/token 你得到了 directLine 令牌。每次调用此 URL 时都会出现 404 错误,似乎那里没有这样的 API。 如果您尚未在代码中实现此类 API,请在您的 .net Framework 项目中尝试以下代码: using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; using System.Web; using System.Web.Http; using Newtonsoft.Json; namespace CoreBot.Controllers { [Route("api/token")] public class TokenController : ApiController { public async Task<IHttpActionResult> token() { var secret = "<your bot channel directline secret>"; HttpClient client = new HttpClient(); HttpRequestMessage request = new HttpRequestMessage( HttpMethod.Post, $"https://directline.botframework.com/v3/directline/tokens/generate"); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", secret); var userId = $"dl_{Guid.NewGuid()}"; request.Content = new StringContent( Newtonsoft.Json.JsonConvert.SerializeObject( new { User = new { Id = userId } }), Encoding.UTF8, "application/json"); var response = await client.SendAsync(request); string token = String.Empty; if (response.IsSuccessStatusCode) { var body = await response.Content.ReadAsStringAsync(); token = JsonConvert.DeserializeObject<DirectLineToken>(body).token; } var config = new ChatConfig() { token = token, userId = userId }; return Ok(config); } } public class DirectLineToken { public string conversationId { get; set; } public string token { get; set; } public int expires_in { get; set; } } public class ChatConfig { public string token { get; set; } public string userId { get; set; } } } 您可以在这里获取机器人频道直线秘密: 要将其集成到您的项目中,请在项目的控制器文件夹下创建一个TokenController.cs文件并将上面的代码粘贴到其中: 并且在您将项目发布到 Azure 后,您将能够通过 URL :https://csharpbotdw.azurewebsites.net/api/token 通过 post 方法获取令牌。 本地测试结果: 启用 CORS 并将代码发布到 Azure 后,您可以使用 HTML 代码连接到您的机器人: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Web Chat: Minimal bundle with Markdown</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <script src="https://cdn.botframework.com/botframework-webchat/latest/webchat-minimal.js"></script> <style> html, body { height: 100%; } body { margin: 0; } #webchat { height: 100%; width: 100%; } </style> </head> <body> <div id="webchat" role="main"></div> <script> (async function() { const res = await fetch('https://csharpbotdw.azurewebsites.net/api/token', { method: 'POST' }); const { token } = await res.json(); window.WebChat.renderWebChat( { directLine: window.WebChat.createDirectLine({ token }) }, document.getElementById('webchat') ); document.querySelector('#webchat > *').focus(); })().catch(err => console.error(err)); </script> </body> </html> 您必须在运行 csharpbotdw 服务的应用程序服务的 CORS 菜单中的已批准来源列表中添加调用域。 如果 DirectLine 或 WebChat 被创建为“Bot Channel Registration”,下面的代码将起作用。 (async()=>{ const styleOptions = { bubbleBackground: 'rgba(0, 0, 255, .1)', bubbleFromUserBackground: 'rgba(0, 255, 0, .1)', rootHeight: '100%', rootWidth: '50%', botAvatarInitials: 'WC', userAvatarInitials: 'WW', }; var response = {}; const body = { "user": { "id": "George", "name": "George" }, "trustedOrigins": [ "http://localhost:5500" ] } const res = await fetch('https://directline.botframework.com/v3/directline/tokens/generate', { method: 'POST' , headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', Authorization: "Bearer <<YOUR_SECRET>>", }, body:JSON.stringify(body) }).then((response) => response.json()) .then((data) => response = data); const tokenString = response.token; console.log("Token " , tokenString ); window.WebChat.renderWebChat( { directLine: window.WebChat.createDirectLine({ token: tokenString }), username: 'George', locale: 'en-US', styleOptions }, document.getElementById('webchat') ); })();

回答 3 投票 0

Bot在Web客户端中启动时不欢迎用户加入

[每当用户加入与我的机器人通过OnMember Leicester方法进行的对话时,我都添加了一条自定义消息,它在Bot Emulator上也能很好地工作,机器人会向他// ...发送主动消息以向用户打招呼。] >> [

回答 1 投票 1

Microsoft Chatbot的自定义聊天界面

我想使用Microsoft Bot框架基于以下图像构建自定义聊天机器人应用程序,它如何与图像和按钮一起使用?我们是否需要处理每个按钮/ card ...

回答 1 投票 0

Bot不能直接在直接行中发送欢迎消息

我已经使用bot框架v4 c#在本地创建了一个bot。它有一个欢迎卡,当我将本地URL与模拟器连接后,该卡会自动弹出,但是最近我在azure上部署了我的机器人,并且...

回答 2 投票 0

无法通过Directline在Webchat中发送附件,相同的代码在模拟器中也可以正常工作

var response = MessageFactory.Attachment(新附件{名称= @“ application.png”,ContentType =“ image / png”,ContentUrl =“ base64sting”});等待dc.Context.SendActivityAsync(...

回答 1 投票 2

无效的尝试重构不可迭代的实例-Bot 4.0 WebChat.js

[[对象错误]:{消息:“无效尝试破坏不可迭代实例的结构”,堆栈:“ TypeError:无效尝试破坏不可迭代实例在e.exports(https://cdn.botframework ....

回答 1 投票 1

将Bot与Direct Line API集成

我有一个在SDK 4中开发并在IIS中部署的机器人。当我使用秘密与网络聊天集成时,它可以工作。 window.WebChat.renderWebChat({directLine:window.WebChat ....

回答 1 投票 0

如果用户在获得响应之前发布下一个问题,则需要向用户发送通知

我已经开发了一个机器人,它正在使用中。有时,bot需要花费更多时间来响应查询。那时,用户连续发布3到4个问题。如果用户发帖,是否有任何选择...

回答 1 投票 0

在团队中使用Azure机器人服务:如何将文件发送到机器人

我是团队和机器人框架开发的新手。我有一个在团队中运行的botframework机器人。我没有使用App Studio,而是直接从Azure机器人服务中导出了它。我想要...

回答 1 投票 1

Director bot在实施令牌而不是秘密后回显输入的消息?

问题我已经开发了自己的API,该API使用Directline API生成和刷新令牌。问题出在那之后,当我在上面的代码中集成令牌而不是Secret时,我的机器人回复了答案...

回答 2 投票 0

[OAuth2 bot注册到消息传递端点

我们有一个本地消息传递端点,botframework需要为聊天活动进行注册和交流。我们的消息传递端点受2way SSL上的Oauth2保护。我们注意到...

回答 1 投票 1

使用没有Azure Bot服务的BotFramework DirectLine

我正在寻找一个Bot,该Bot集成了他们提供的Bot Framework DirectLine API。但是,我希望该服务与Cloud Service无关。因此,想法是使用BotFramework功能...

回答 1 投票 0

在botframework中,一旦用户回复,如何将已发送的消息修改为团队频道

我正在尝试修改Bot发送给用户的最后一条消息,用户响应后。为此,我正在尝试使用需要会话ID和活动ID的rest API。我面临的问题是...

回答 1 投票 0

如何为对话框配置DirectLineSpeech?

我如何配置“ Speak()”以说出提示和其他瀑布式消息,例如DirectLineSpeech的DirectLine语音回声bot示例?我尝试使用DirectLine语音核-...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.