diff --git a/BotSharp.Channel.FacebookMessenger/BotSharp.Channel.FacebookMessenger.csproj b/BotSharp.Channel.FacebookMessenger/BotSharp.Channel.FacebookMessenger.csproj
index f67b33ee..b68aaa1e 100644
--- a/BotSharp.Channel.FacebookMessenger/BotSharp.Channel.FacebookMessenger.csproj
+++ b/BotSharp.Channel.FacebookMessenger/BotSharp.Channel.FacebookMessenger.csproj
@@ -10,13 +10,11 @@
+
-
-
-
diff --git a/BotSharp.Channel.Weixin/BotSharp.Channel.Weixin.csproj b/BotSharp.Channel.Weixin/BotSharp.Channel.Weixin.csproj
index e74df3f9..4a11168b 100644
--- a/BotSharp.Channel.Weixin/BotSharp.Channel.Weixin.csproj
+++ b/BotSharp.Channel.Weixin/BotSharp.Channel.Weixin.csproj
@@ -24,10 +24,7 @@
-
-
-
diff --git a/BotSharp.Channel.Weixin/Controllers/WeixinAsyncController.cs b/BotSharp.Channel.Weixin/Controllers/WeixinAsyncController.cs
index 65e8a44b..6bf03cf7 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.Dialogflow.Models;
+using BotSharp.Platform.OwnThink.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 e67f7dd1..b8a6a648 100644
--- a/BotSharp.Channel.Weixin/Models/CustomMessageHandler.cs
+++ b/BotSharp.Channel.Weixin/Models/CustomMessageHandler.cs
@@ -31,8 +31,8 @@ using Senparc.Weixin;
using Senparc.Weixin.MP;
using BotSharp.Platform.Models.AiRequest;
using BotSharp.Platform.Abstractions;
-using BotSharp.Platform.Dialogflow.Models;
using Microsoft.Extensions.Configuration;
+using BotSharp.Platform.OwnThink.Models;
#if NET45
using System.Web;
diff --git a/BotSharp.Core/Models/Agents/AgentCreationViewModel.cs b/BotSharp.Core/Models/Agents/AgentCreationRequestModel.cs
similarity index 67%
rename from BotSharp.Core/Models/Agents/AgentCreationViewModel.cs
rename to BotSharp.Core/Models/Agents/AgentCreationRequestModel.cs
index 85b3c93e..ec2a5a1c 100644
--- a/BotSharp.Core/Models/Agents/AgentCreationViewModel.cs
+++ b/BotSharp.Core/Models/Agents/AgentCreationRequestModel.cs
@@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
using System.Text;
namespace BotSharp.Platform.Models.Agents
{
- public class AgentCreationViewModel
+ public class AgentCreationRequestModel
{
+ [Required]
public string Name { get; set; }
public string Description { get; set; }
diff --git a/BotSharp.Core/Models/Agents/AgentCreationResponseModel.cs b/BotSharp.Core/Models/Agents/AgentCreationResponseModel.cs
new file mode 100644
index 00000000..7d346117
--- /dev/null
+++ b/BotSharp.Core/Models/Agents/AgentCreationResponseModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace BotSharp.Platform.Models.Agents
+{
+ public class AgentCreationResponseModel
+ {
+ public string AgentId { get; set; }
+
+ public string Name { get; set; }
+
+ public string ClientAccessToken { get; set; }
+ }
+}
diff --git a/BotSharp.Platform.OwnThink/BotSharp.Platform.OwnThink.csproj b/BotSharp.Platform.OwnThink/BotSharp.Platform.OwnThink.csproj
index 9b2b8c48..1855c819 100644
--- a/BotSharp.Platform.OwnThink/BotSharp.Platform.OwnThink.csproj
+++ b/BotSharp.Platform.OwnThink/BotSharp.Platform.OwnThink.csproj
@@ -1,11 +1,11 @@
-
+
netcoreapp2.2
-
+
diff --git a/BotSharp.Platform.OwnThink/Controllers/AgentController.cs b/BotSharp.Platform.OwnThink/Controllers/AgentController.cs
index 842b96d7..7a33cc95 100644
--- a/BotSharp.Platform.OwnThink/Controllers/AgentController.cs
+++ b/BotSharp.Platform.OwnThink/Controllers/AgentController.cs
@@ -1,10 +1,56 @@
-using System;
+using BotSharp.Platform.Models.Agents;
+using BotSharp.Platform.OwnThink.Models;
+using BotSharp.Platform.OwnThink.ViewModels;
+using Microsoft.AspNetCore.Mvc;
+using System;
using System.Collections.Generic;
using System.Text;
+using System.Threading.Tasks;
namespace BotSharp.Platform.OwnThink.Controllers
{
- public class AgentController
+ [Route("v1/[controller]")]
+ public class AgentController : ControllerBase
{
+ private OwnThinkAi builder;
+
+ ///
+ /// Initialize dialog controller and get a platform instance
+ ///
+ ///
+ public AgentController(OwnThinkAi platform)
+ {
+ builder = platform;
+ }
+
+ ///
+ /// Create agent
+ ///
+ ///
+ ///
+ [HttpPost]
+ [ProducesResponseType(typeof(AgentCreationResponseViewModel), 200)]
+ public async Task Create(AgentCreationRequestViewModel requestViewModel)
+ {
+ var agent = new AgentModel()
+ {
+ Id = Guid.NewGuid().ToString(),
+ Name = requestViewModel.Name,
+ Description = requestViewModel.Name,
+ AppId = requestViewModel.AppId,
+ ClientAccessToken = Guid.NewGuid().ToString("N"),
+ DeveloperAccessToken = Guid.NewGuid().ToString("N")
+ };
+
+ await builder.SaveAgent(agent);
+
+ return Ok(new AgentCreationResponseViewModel
+ {
+ AgentId = agent.Id,
+ AppId = agent.AppId,
+ Name = agent.Name,
+ ClientAccessToken = agent.ClientAccessToken
+ });
+ }
}
}
diff --git a/BotSharp.Platform.OwnThink/Controllers/QueryController.cs b/BotSharp.Platform.OwnThink/Controllers/QueryController.cs
new file mode 100644
index 00000000..da220707
--- /dev/null
+++ b/BotSharp.Platform.OwnThink/Controllers/QueryController.cs
@@ -0,0 +1,55 @@
+using BotSharp.Platform.Models.AiRequest;
+using BotSharp.Platform.OwnThink.Models;
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Claims;
+using System.Text;
+
+namespace BotSharp.Platform.OwnThink.Controllers
+{
+ [Route("v1/[controller]")]
+ public class QueryController : ControllerBase
+ {
+ private OwnThinkAi builder;
+
+ public QueryController(OwnThinkAi platform)
+ {
+ builder = platform;
+ }
+
+ /*[HttpGet, HttpPost]
+ public async Task> Query(QueryModel request)
+ {
+ String clientAccessToken = (User.Identity as ClaimsIdentity).Claims.FirstOrDefault(x => x.Type == "UserId")?.Value;
+
+ // find a model according to clientAccessToken
+
+ var agents = await builder.GetAllAgents();
+ var agent = agents.FirstOrDefault(x => x.ClientAccessToken == clientAccessToken);
+
+ if (agent == null)
+ {
+ return BadRequest("The agent not found.");
+ }
+
+ var aIResponse = await builder.TextRequest(new AiRequest
+ {
+ Text = request.Query,
+ AgentId = agent.Id,
+ SessionId = request.SessionId
+ });
+
+ return new AIResponse
+ {
+ 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/AIResponseFulfillment.cs b/BotSharp.Platform.OwnThink/Models/AIResponseFulfillment.cs
new file mode 100644
index 00000000..77498336
--- /dev/null
+++ b/BotSharp.Platform.OwnThink/Models/AIResponseFulfillment.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace BotSharp.Platform.OwnThink.Models
+{
+ public class AIResponseFulfillment
+ {
+ public string Speech { get; set; }
+
+ public List