1

我目前正在开发 .net mvc 5 应用程序,我想在其中为使用 Api.ai 制作的代理添加集成。我也在使用 SignalR 来确保客户端和服务器之间的异步通信。问题是,我不断丢失对话的上下文并且参数丢失并且机器人不断要求它们。

我的 SignalR 集线器的代码:

public class SupportHub : Hub
    {
        ApiAiUtility ai = new ApiAiUtility();
        public void Send(string message)
        {
            var response = ai.Ai.TextRequest(message);

            if (response.Result.GetStringParameter("subject") != "" &&
                response.Result.GetStringParameter("description") != "")
            {
                //TODO: Add code to handle adding the ticket to database

            }
            Clients.All.echoBack(response.Result.Contexts);

        }

我怀疑集线器没有与 Api.ai 保持联系。

4

1 回答 1

0

我通过改变这一行解决了这个问题:

ApiAiUtility ai = new ApiAiUtility();

对此:

static ApiAiUtility ai = new ApiAiUtility();
于 2016-11-23T02:55:12.290 回答