diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..b0be1285
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,3 @@
+ bin/
+ obj/
+ node_modules/
\ No newline at end of file
diff --git a/BotSharp.RestApi/BotSharp.RestApi.csproj b/BotSharp.RestApi/BotSharp.RestApi.csproj
index 6c85eac9..7cbd306a 100644
--- a/BotSharp.RestApi/BotSharp.RestApi.csproj
+++ b/BotSharp.RestApi/BotSharp.RestApi.csproj
@@ -19,6 +19,11 @@
bin\Debug\netcoreapp2.1\BotSharp.RestApi.xml
+ TRACE;DEBUG;MODE_DIALOGFLOW
+
+
+
+ TRACE;MODE_DIALOGFLOW
diff --git a/BotSharp.RestApi/Dialogs/DialogController.cs b/BotSharp.RestApi/Dialogflow/QueryController.cs
similarity index 80%
rename from BotSharp.RestApi/Dialogs/DialogController.cs
rename to BotSharp.RestApi/Dialogflow/QueryController.cs
index 4ec6894b..15c546e3 100644
--- a/BotSharp.RestApi/Dialogs/DialogController.cs
+++ b/BotSharp.RestApi/Dialogflow/QueryController.cs
@@ -2,20 +2,20 @@
using BotSharp.Core.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
-using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
-namespace BotSharp.RestApi.Dialogs
+namespace BotSharp.RestApi.Dialogflow
{
+#if MODE_DIALOGFLOW
///
- /// Conversation controller
+ /// Dialogflow mode query controller
///
[Authorize]
[Route("v1/[controller]")]
- public class DialogController : ControllerBase
+ public class QueryController : ControllerBase
{
private readonly IBotPlatform _platform;
@@ -23,7 +23,7 @@ namespace BotSharp.RestApi.Dialogs
/// Initialize dialog controller and get a platform instance
///
///
- public DialogController(IBotPlatform platform)
+ public QueryController(IBotPlatform platform)
{
_platform = platform;
}
@@ -31,11 +31,12 @@ namespace BotSharp.RestApi.Dialogs
///
/// The query endpoint is used to process natural language in the form of text.
/// The query requests return structured data in JSON format with an action and parameters for that action.
+ /// Both GET and POST methods return the same JSON response.
///
///
///
- [HttpPost("/v1/query")]
- public ActionResult Query([FromBody] QueryModel request)
+ [HttpGet, HttpPost]
+ public ActionResult Query(QueryModel request)
{
String clientAccessToken = Request.Headers["ClientAccessToken"];
var config = new AIConfiguration(clientAccessToken, SupportedLanguage.English);
@@ -50,8 +51,9 @@ namespace BotSharp.RestApi.Dialogs
Language = request.Lang,
Query = new String[] { request.Query }
});
-
+
return aIResponse;
}
}
+#endif
}
diff --git a/BotSharp.RestApi/Dialogflow/QueryModel.cs b/BotSharp.RestApi/Dialogflow/QueryModel.cs
new file mode 100644
index 00000000..643b1d05
--- /dev/null
+++ b/BotSharp.RestApi/Dialogflow/QueryModel.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Text;
+
+namespace BotSharp.RestApi.Dialogflow
+{
+ public class QueryModel
+ {
+ public QueryModel()
+ {
+ Contexts = new List();
+ }
+
+ ///
+ /// Array of additional context objects. Should be sent via a POST /query request.
+ /// Contexts sent in a query are activated before the query.
+ ///
+ public List Contexts { get; set; }
+
+ ///
+ /// Object containing event name and additional data.
+ /// The "data" parameter can be submitted only in POST requests.
+ ///
+ public String Event { get;set; }
+
+ ///
+ /// Language tag, e.g., en, es etc.
+ ///
+ public String Lang { get; set; }
+
+ ///
+ /// Natural language text to be processed. Query length should not exceed 256 characters.
+ ///
+ [Required]
+ public String Query { get; set; }
+
+ ///
+ /// A string token up to 36 symbols long, used to identify the client and to manage session parameters (including contexts) per client.
+ ///
+ [Required]
+ public String SessionId { get; set; }
+
+ ///
+ /// Time zone from IANA Time Zone Database Examples: America/New_York, Europe/Paris
+ ///
+ public String Timezone { get; set; }
+ }
+}
diff --git a/BotSharp.RestApi/Dialogs/QueryModel.cs b/BotSharp.RestApi/Dialogs/QueryModel.cs
deleted file mode 100644
index d08257df..00000000
--- a/BotSharp.RestApi/Dialogs/QueryModel.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Text;
-
-namespace BotSharp.RestApi.Dialogs
-{
- public class QueryModel
- {
- public List Contexts { get; set; }
-
- public String Event { get;set; }
-
- public String Lang { get; set; }
-
- ///
- /// User says
- ///
- [Required]
- public String Query { get; set; }
-
- [Required]
- public String SessionId { get; set; }
-
- public String Timezone { get; set; }
- }
-}
diff --git a/Dockerfile b/Dockerfile
index 7ae5336b..03a9c1a7 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,14 @@
+# stage 1: build
+FROM microsoft/aspnetcore-build AS builder
+WORKDIR /source
+
+ # copies the rest of your code
+COPY . .
+RUN dotnet build
+RUN dotnet publish --output /app/ --configuration Release
+
+# stage 2: install
FROM microsoft/aspnetcore
WORKDIR /app
-COPY ./BotSharp.WebHost/PublishOutput .
-# ENTRYPOINT [ "dotnet", "BotSharp.WebHost.dll" ]
\ No newline at end of file
+COPY --from=builder /app .
+ENTRYPOINT [ "dotnet", "BotSharp.WebHost.dll" ]
\ No newline at end of file