首页 > 解决方案 > 基于 Microsoft Bot Framework 连接到本地 echo bot 的离线直连路由

问题描述

我想使用托管在本地环境中的 pierre3 提供的 API 包装器创建一个 Line 消息传递机器人。

Line Messaging Service ~~POST~~> WebApi.Net ~X-> Offline-Directline ---> Echobot (Bot Framework)

我正在使用节点包“offline-directline”,它应该能够将消息路由到本地机器人,该机器人是从 Microsoft BotFramework Extension 中捆绑的 Echobot 模板创建的。

这是节点终端上打印的文本:

Offline-Directline: Listening for messages from client on http://127.0.0.1:3000
Routing messages to bot on http://localhost:3978/api/messages

到目前为止,我的 webapi 能够接收来自 Line Messenging Service 的请求。

问题是我不知道如何从 webapi 连接到离线直连。

DirectLineClient 不会抛出异常,但是每当 webapi 执行 StartConversationAsync() 时,会话总是返回 null。

我可以确认我的 Echobot 正在工作,因为我可以使用 Bot Framework Emulator 与之交互。

var uri = new Uri("http://localhost:3978/api/messages");
var cred = new DirectLineClientCredentials(null, http://localhost:3000/directline");
this.dlClient = new DirectLineClient(uri, cred);

var conversation = await dlClient.Conversations.StartConversationAsync();
//this is always return null

我希望当我通过 Line Messenger 发送文本“hello world”时,机器人会在 Line Messenger 上回复相同的文本“hello world”。

对于额外的信息,我不确定这是否相关:Line Messaging Api Wrapper 需要使用 Azure blob 存储。我没有在线 Azure Blob 存储,而是使用存储模拟器并将连接字符串设置为“UseDevelopmentStorage=true”。我认为这是有效的,因为我检查了 CloudBlobClient 的实例不为空,并且它包含指向本地模拟器的有效 uri。

--

我已经坚持了好几个小时但没有任何线索。任何帮助将非常感激。

标签: c#asp.net-web-apibotframeworkdirect-line-botframeworkline-messenger

解决方案


推荐阅读