diff --git a/BotSharp.Channel.FacebookMessenger/BotSharp.Channel.FacebookMessenger.csproj b/BotSharp.Channel.FacebookMessenger/BotSharp.Channel.FacebookMessenger.csproj index b68aaa1e..e99aa1c9 100644 --- a/BotSharp.Channel.FacebookMessenger/BotSharp.Channel.FacebookMessenger.csproj +++ b/BotSharp.Channel.FacebookMessenger/BotSharp.Channel.FacebookMessenger.csproj @@ -14,7 +14,7 @@ - + diff --git a/BotSharp.Channel.Weixin/BotSharp.Channel.Weixin.csproj b/BotSharp.Channel.Weixin/BotSharp.Channel.Weixin.csproj index 4a11168b..674681de 100644 --- a/BotSharp.Channel.Weixin/BotSharp.Channel.Weixin.csproj +++ b/BotSharp.Channel.Weixin/BotSharp.Channel.Weixin.csproj @@ -24,7 +24,7 @@ - + diff --git a/BotSharp.Channel.Weixin/Controllers/WeixinAsyncController.cs b/BotSharp.Channel.Weixin/Controllers/WeixinAsyncController.cs index 6bf03cf7..65e8a44b 100644 --- a/BotSharp.Channel.Weixin/Controllers/WeixinAsyncController.cs +++ b/BotSharp.Channel.Weixin/Controllers/WeixinAsyncController.cs @@ -1,6 +1,6 @@ using BotSharp.Channel.Weixin.Models; using BotSharp.Platform.Abstractions; -using BotSharp.Platform.OwnThink.Models; +using BotSharp.Platform.Dialogflow.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Senparc.CO2NET.HttpUtility; diff --git a/BotSharp.Channel.Weixin/Models/CustomMessageHandler.cs b/BotSharp.Channel.Weixin/Models/CustomMessageHandler.cs index b8a6a648..cf28898a 100644 --- a/BotSharp.Channel.Weixin/Models/CustomMessageHandler.cs +++ b/BotSharp.Channel.Weixin/Models/CustomMessageHandler.cs @@ -32,7 +32,7 @@ using Senparc.Weixin.MP; using BotSharp.Platform.Models.AiRequest; using BotSharp.Platform.Abstractions; using Microsoft.Extensions.Configuration; -using BotSharp.Platform.OwnThink.Models; +using BotSharp.Platform.Dialogflow.Models; #if NET45 using System.Web; diff --git a/BotSharp.Platform.OwnThink/Controllers/QueryController.cs b/BotSharp.Platform.OwnThink/Controllers/QueryController.cs index da220707..b457ff1a 100644 --- a/BotSharp.Platform.OwnThink/Controllers/QueryController.cs +++ b/BotSharp.Platform.OwnThink/Controllers/QueryController.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Security.Claims; using System.Text; +using System.Threading.Tasks; namespace BotSharp.Platform.OwnThink.Controllers { @@ -19,8 +20,8 @@ namespace BotSharp.Platform.OwnThink.Controllers builder = platform; } - /*[HttpGet, HttpPost] - public async Task> Query(QueryModel request) + [HttpGet, HttpPost] + public async Task> Query(OwnThinkAiRequest request) { String clientAccessToken = (User.Identity as ClaimsIdentity).Claims.FirstOrDefault(x => x.Type == "UserId")?.Value; @@ -36,20 +37,15 @@ namespace BotSharp.Platform.OwnThink.Controllers var aIResponse = await builder.TextRequest(new AiRequest { - Text = request.Query, + Text = request.Spoken, AgentId = agent.Id, - SessionId = request.SessionId + SessionId = request.AppId }); - return new AIResponse + return new OwnThinkAiResponse { - Result = aIResponse, - Id = Guid.NewGuid().ToString(), - Lang = request.Lang, - SessionId = request.SessionId, - Status = new AIResponseStatus(), - Timestamp = DateTime.UtcNow + }; - }*/ + } } } diff --git a/BotSharp.Platform.OwnThink/Models/OwnThinkAiRequest.cs b/BotSharp.Platform.OwnThink/Models/OwnThinkAiRequest.cs new file mode 100644 index 00000000..5f86b8f7 --- /dev/null +++ b/BotSharp.Platform.OwnThink/Models/OwnThinkAiRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BotSharp.Platform.OwnThink.Models +{ + public class OwnThinkAiRequest + { + public string AppId { get; set; } + + public string Spoken { get; set; } + } +} diff --git a/BotSharp.Platform.OwnThink/Models/OwnThinkChatResponse.cs b/BotSharp.Platform.OwnThink/Models/OwnThinkAiResponse.cs similarity index 92% rename from BotSharp.Platform.OwnThink/Models/OwnThinkChatResponse.cs rename to BotSharp.Platform.OwnThink/Models/OwnThinkAiResponse.cs index 9f2c6732..813820d4 100644 --- a/BotSharp.Platform.OwnThink/Models/OwnThinkChatResponse.cs +++ b/BotSharp.Platform.OwnThink/Models/OwnThinkAiResponse.cs @@ -4,7 +4,7 @@ using System.Text; namespace BotSharp.Platform.OwnThink.Models { - public class OwnThinkChatResponse + public class OwnThinkAiResponse { public OwnThinkChatResponseData Data { get; set; } diff --git a/BotSharp.Platform.OwnThink/OwnThinkAi.cs b/BotSharp.Platform.OwnThink/OwnThinkAi.cs index ff660e27..f32f8bdc 100644 --- a/BotSharp.Platform.OwnThink/OwnThinkAi.cs +++ b/BotSharp.Platform.OwnThink/OwnThinkAi.cs @@ -102,7 +102,7 @@ namespace BotSharp.Platform.OwnThink "https://api.ownthink.com/bot", new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json")); var content = await response.Content.ReadAsStringAsync(); - var result = JsonConvert.DeserializeObject(content); + var result = JsonConvert.DeserializeObject(content); return new TextClassificationResult { diff --git a/BotSharp.WebHost/Settings/app.json b/BotSharp.WebHost/Settings/app.json index bd3d6639..3e813262 100644 --- a/BotSharp.WebHost/Settings/app.json +++ b/BotSharp.WebHost/Settings/app.json @@ -1,8 +1,8 @@ { - "version": "0.2.0", + "version": "0.5.0", "assemblies": "BotSharp.Core", - "platformModuleName": "OwnThinkAi", + "platformModuleName": "DialogflowAi", "overrideFallback": false, "modules": [