Skip to content

Commit e3da73b

Browse files
authored
Merge pull request #698 from yileicn/master
Add a ChannelId column to the ConversationDocument
2 parents 8813403 + f635bbc commit e3da73b

File tree

6 files changed

+11
-1
lines changed

6 files changed

+11
-1
lines changed

src/Infrastructure/BotSharp.Abstraction/Conversations/Models/Conversation.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ public class Conversation
2424

2525
public string Channel { get; set; } = ConversationChannel.OpenAPI;
2626

27+
/// <summary>
28+
/// Channel id, like phone number, email address, etc.
29+
/// </summary>
30+
public string ChannelId { get; set; }
31+
2732
public int DialogCount { get; set; }
2833

2934
public List<string> Tags { get; set; } = new();

src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,12 @@ public async Task<Conversation> GetConversationRecordOrCreateNew(string agentId)
172172
{
173173
var state = _services.GetRequiredService<IConversationStateService>();
174174
var channel = state.GetState("channel");
175+
var channelId = state.GetState("channel_id");
175176
var sess = new Conversation
176177
{
177178
Id = _conversationId,
178179
Channel = channel,
180+
ChannelId = channelId,
179181
AgentId = agentId
180182
};
181183
converation = await NewConversation(sess);

src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Conversation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public void CreateNewConversation(Conversation conversation)
1010
var utcNow = DateTime.UtcNow;
1111
conversation.CreatedTime = utcNow;
1212
conversation.UpdatedTime = utcNow;
13-
conversation.Tags = conversation.Tags ?? new();
13+
conversation.Tags ??= new();
1414

1515
var dir = Path.Combine(_dbSettings.FileRepository, _conversationSettings.DataDir, conversation.Id);
1616
if (!Directory.Exists(dir))

src/Plugins/BotSharp.Plugin.MongoStorage/Collections/ConversationDocument.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class ConversationDocument : MongoBase
77
public string? TaskId { get; set; }
88
public string Title { get; set; }
99
public string Channel { get; set; }
10+
public string ChannelId { get; set; }
1011
public string Status { get; set; }
1112
public int DialogCount { get; set; }
1213
public List<string> Tags { get; set; }

src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Conversation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public void CreateNewConversation(Conversation conversation)
1717
UserId = !string.IsNullOrEmpty(conversation.UserId) ? conversation.UserId : string.Empty,
1818
Title = conversation.Title,
1919
Channel = conversation.Channel,
20+
ChannelId = conversation.ChannelId,
2021
TaskId = conversation.TaskId,
2122
Status = conversation.Status,
2223
Tags = conversation.Tags ?? new(),

src/Plugins/BotSharp.Plugin.Twilio/Services/TwilioMessageQueueService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ private static void InitConversation(CallerMessage message, RoleDialogModel inpu
108108
var states = new List<MessageState>
109109
{
110110
new("channel", ConversationChannel.Phone),
111+
new("channel_id", message.From),
111112
new("calling_phone", message.From)
112113
};
113114
states.AddRange(message.States.Select(kvp => new MessageState(kvp.Key, kvp.Value)));

0 commit comments

Comments
 (0)