diff --git a/BotSharp.Core/Adapters/Dialogflow/DialogflowIntentResponseParameter.cs b/BotSharp.Core/Adapters/Dialogflow/DialogflowIntentResponseParameter.cs index 153c8650..b0e96c4b 100644 --- a/BotSharp.Core/Adapters/Dialogflow/DialogflowIntentResponseParameter.cs +++ b/BotSharp.Core/Adapters/Dialogflow/DialogflowIntentResponseParameter.cs @@ -9,8 +9,11 @@ namespace BotSharp.Core.Adapters.Dialogflow public string Id { get; set; } public bool Required { get; set; } public string DataType { get; set; } + public string DefaultValue { get; set; } public string Name { get; set; } public string Value { get; set; } public bool IsList { get; set; } + + public List PromptList { get; set; } } } diff --git a/BotSharp.Core/Adapters/Dialogflow/DialogflowIntentResponseParameterPrompt.cs b/BotSharp.Core/Adapters/Dialogflow/DialogflowIntentResponseParameterPrompt.cs new file mode 100644 index 00000000..9c403a19 --- /dev/null +++ b/BotSharp.Core/Adapters/Dialogflow/DialogflowIntentResponseParameterPrompt.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BotSharp.Core.Adapters.Dialogflow +{ + public class DialogflowIntentResponseParameterPrompt + { + public string Lang { get; set; } + + public string Value { get; set; } + } +} diff --git a/BotSharp.Core/Agents/AgentDriver.cs b/BotSharp.Core/Agents/AgentDriver.cs index b8444af9..0c72ca82 100644 --- a/BotSharp.Core/Agents/AgentDriver.cs +++ b/BotSharp.Core/Agents/AgentDriver.cs @@ -1,7 +1,6 @@ using BotSharp.Core.Adapters.Rasa; using BotSharp.Core.Engines; using BotSharp.Core.Entities; -using BotSharp.Core.Expressions; using BotSharp.Core.Intents; using BotSharp.Core.Models; using EntityFrameworkCore.BootKit; diff --git a/BotSharp.Core/Engines/AgentImporterInDialogflow.cs b/BotSharp.Core/Engines/AgentImporterInDialogflow.cs index 447abf81..d0da5418 100644 --- a/BotSharp.Core/Engines/AgentImporterInDialogflow.cs +++ b/BotSharp.Core/Engines/AgentImporterInDialogflow.cs @@ -79,6 +79,7 @@ namespace BotSharp.Core.Engines // avoid confict data structure intentJson = intentJson.Replace("\"contexts\":", "\"contextList\":"); intentJson = intentJson.Replace("\"messages\":", "\"messageList\":"); + intentJson = intentJson.Replace("\"prompts\":", "\"promptList\":"); var intent = JsonConvert.DeserializeObject(intentJson); @@ -124,6 +125,13 @@ namespace BotSharp.Core.Engines } }).ToList(); + + newResponse.Parameters = res.Parameters.Select(p => + { + var rp = p.ToObject(); + rp.Prompts = p.PromptList.Select(pl => new ResponseParameterPrompt { Prompt = pl.Value }).ToList(); + return rp; + }).ToList(); }); newIntent.Contexts = intent.ContextList.Select(x => new IntentInputContext { Name = x }).ToList(); diff --git a/BotSharp.Core/Intents/IntentDriver.cs b/BotSharp.Core/Intents/IntentDriver.cs index 28b510cf..48e9b780 100644 --- a/BotSharp.Core/Intents/IntentDriver.cs +++ b/BotSharp.Core/Intents/IntentDriver.cs @@ -16,7 +16,7 @@ namespace BotSharp.Core.Intents var intent = dc.Table() .Include(x => x.Contexts) .Include(x => x.Responses).ThenInclude(x => x.Contexts) - .Include(x => x.Responses).ThenInclude(x => x.Parameters) + .Include(x => x.Responses).ThenInclude(x => x.Parameters).ThenInclude(x => x.Prompts) .Include(x => x.Responses).ThenInclude(x => x.Messages) .Include(x => x.UserSays).ThenInclude(x => x.Data) .FirstOrDefault(x => x.Id == intentId); diff --git a/BotSharp.Core/Intents/IntentExpression.cs b/BotSharp.Core/Intents/IntentExpression.cs index 538d86b6..c75d62a6 100644 --- a/BotSharp.Core/Intents/IntentExpression.cs +++ b/BotSharp.Core/Intents/IntentExpression.cs @@ -1,5 +1,4 @@ -using BotSharp.Core.Expressions; -using EntityFrameworkCore.BootKit; +using EntityFrameworkCore.BootKit; using Newtonsoft.Json; using System; using System.Collections.Generic; diff --git a/BotSharp.Core/Expressions/IntentExpressionPart.cs b/BotSharp.Core/Intents/IntentExpressionPart.cs similarity index 94% rename from BotSharp.Core/Expressions/IntentExpressionPart.cs rename to BotSharp.Core/Intents/IntentExpressionPart.cs index 3d4d93c5..e6e23668 100644 --- a/BotSharp.Core/Expressions/IntentExpressionPart.cs +++ b/BotSharp.Core/Intents/IntentExpressionPart.cs @@ -5,7 +5,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text; -namespace BotSharp.Core.Expressions +namespace BotSharp.Core.Intents { [Table("Bot_IntentExpressionPart")] public class IntentExpressionPart : DbRecord, IDbRecord diff --git a/BotSharp.Core/Intents/IntentResponseParameter.cs b/BotSharp.Core/Intents/IntentResponseParameter.cs index 9b0c3a9b..05cb1a3c 100644 --- a/BotSharp.Core/Intents/IntentResponseParameter.cs +++ b/BotSharp.Core/Intents/IntentResponseParameter.cs @@ -29,5 +29,8 @@ namespace BotSharp.Core.Intents public string Value { get; set; } public bool IsList { get; set; } + + [ForeignKey("ResponseParameterId")] + public List Prompts { get; set; } } } diff --git a/BotSharp.Core/Intents/ResponseParameterPrompt.cs b/BotSharp.Core/Intents/ResponseParameterPrompt.cs new file mode 100644 index 00000000..6142b8db --- /dev/null +++ b/BotSharp.Core/Intents/ResponseParameterPrompt.cs @@ -0,0 +1,20 @@ +using EntityFrameworkCore.BootKit; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; + +namespace BotSharp.Core.Intents +{ + [Table("Bot_ResponseParameterPrompt")] + public class ResponseParameterPrompt : DbRecord, IDbRecord + { + [Required] + [StringLength(36)] + public String ResponseParameterId { get; set; } + + [MaxLength(256)] + public string Prompt { get; set; } + } +} diff --git a/BotSharp.Core/Models/RasaIntentExpression.cs b/BotSharp.Core/Models/RasaIntentExpression.cs index 480e711c..b7562340 100644 --- a/BotSharp.Core/Models/RasaIntentExpression.cs +++ b/BotSharp.Core/Models/RasaIntentExpression.cs @@ -1,5 +1,4 @@ -using BotSharp.Core.Expressions; -using System; +using System; using System.Collections.Generic; using System.Text;