Merge pull request #698 from yileicn/master

Add a ChannelId column to the ConversationDocument
This commit is contained in:
Haiping 2024-10-24 21:23:09 -05:00 committed by GitHub
commit e3da73b417
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 11 additions and 1 deletions

View file

@ -24,6 +24,11 @@ public class Conversation
public string Channel { get; set; } = ConversationChannel.OpenAPI;
/// <summary>
/// Channel id, like phone number, email address, etc.
/// </summary>
public string ChannelId { get; set; }
public int DialogCount { get; set; }
public List<string> Tags { get; set; } = new();

View file

@ -172,10 +172,12 @@ public partial class ConversationService : IConversationService
{
var state = _services.GetRequiredService<IConversationStateService>();
var channel = state.GetState("channel");
var channelId = state.GetState("channel_id");
var sess = new Conversation
{
Id = _conversationId,
Channel = channel,
ChannelId = channelId,
AgentId = agentId
};
converation = await NewConversation(sess);

View file

@ -10,7 +10,7 @@ namespace BotSharp.Core.Repository
var utcNow = DateTime.UtcNow;
conversation.CreatedTime = utcNow;
conversation.UpdatedTime = utcNow;
conversation.Tags = conversation.Tags ?? new();
conversation.Tags ??= new();
var dir = Path.Combine(_dbSettings.FileRepository, _conversationSettings.DataDir, conversation.Id);
if (!Directory.Exists(dir))

View file

@ -7,6 +7,7 @@ public class ConversationDocument : MongoBase
public string? TaskId { get; set; }
public string Title { get; set; }
public string Channel { get; set; }
public string ChannelId { get; set; }
public string Status { get; set; }
public int DialogCount { get; set; }
public List<string> Tags { get; set; }

View file

@ -17,6 +17,7 @@ public partial class MongoRepository
UserId = !string.IsNullOrEmpty(conversation.UserId) ? conversation.UserId : string.Empty,
Title = conversation.Title,
Channel = conversation.Channel,
ChannelId = conversation.ChannelId,
TaskId = conversation.TaskId,
Status = conversation.Status,
Tags = conversation.Tags ?? new(),

View file

@ -108,6 +108,7 @@ namespace BotSharp.Plugin.Twilio.Services
var states = new List<MessageState>
{
new("channel", ConversationChannel.Phone),
new("channel_id", message.From),
new("calling_phone", message.From)
};
states.AddRange(message.States.Select(kvp => new MessageState(kvp.Key, kvp.Value)));