fix welcome message
This commit is contained in:
parent
8b0ecc89bd
commit
cd5456af79
|
|
@ -1,5 +1,4 @@
|
||||||
using BotSharp.Abstraction.Messaging;
|
using BotSharp.Abstraction.Messaging;
|
||||||
using BotSharp.Abstraction.Messaging.Enums;
|
|
||||||
using BotSharp.Abstraction.Messaging.Models.RichContent;
|
using BotSharp.Abstraction.Messaging.Models.RichContent;
|
||||||
|
|
||||||
namespace BotSharp.Core.Messaging;
|
namespace BotSharp.Core.Messaging;
|
||||||
|
|
|
||||||
|
|
@ -35,20 +35,25 @@ public class WelcomeHook : ConversationHookBase
|
||||||
// Render template
|
// Render template
|
||||||
var templating = _services.GetRequiredService<ITemplateRender>();
|
var templating = _services.GetRequiredService<ITemplateRender>();
|
||||||
var user = _services.GetRequiredService<IUserIdentity>();
|
var user = _services.GetRequiredService<IUserIdentity>();
|
||||||
var richContent = templating.Render(welcomeTemplate.Content, new Dictionary<string, object>
|
var content = templating.Render(welcomeTemplate.Content, new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
{ "user", user }
|
{ "user", user }
|
||||||
});
|
});
|
||||||
var richContentService = _services.GetRequiredService<IRichContentService>();
|
var richContentService = _services.GetRequiredService<IRichContentService>();
|
||||||
var messages = richContentService.ConvertToMessages(richContent);
|
var messages = richContentService.ConvertToMessages(content);
|
||||||
|
|
||||||
foreach (var message in messages)
|
foreach (var message in messages)
|
||||||
{
|
{
|
||||||
|
var richContent = new RichContent<IRichMessage>(message)
|
||||||
|
{
|
||||||
|
Editor = message.RichType == RichTypeEnum.QuickReply ? EditorTypeEnum.None : EditorTypeEnum.Text,
|
||||||
|
};
|
||||||
|
|
||||||
var json = JsonSerializer.Serialize(new ChatResponseModel()
|
var json = JsonSerializer.Serialize(new ChatResponseModel()
|
||||||
{
|
{
|
||||||
ConversationId = conversation.Id,
|
ConversationId = conversation.Id,
|
||||||
Text = message.Text,
|
Text = message.Text,
|
||||||
RichContent = new RichContent<IRichMessage>(message),
|
RichContent = richContent,
|
||||||
Sender = new UserViewModel()
|
Sender = new UserViewModel()
|
||||||
{
|
{
|
||||||
FirstName = agent.Name,
|
FirstName = agent.Name,
|
||||||
|
|
@ -63,6 +68,7 @@ public class WelcomeHook : ConversationHookBase
|
||||||
{
|
{
|
||||||
MessageId = conversation.Id,
|
MessageId = conversation.Id,
|
||||||
CurrentAgentId = agent.Id,
|
CurrentAgentId = agent.Id,
|
||||||
|
RichContent = richContent
|
||||||
});
|
});
|
||||||
|
|
||||||
await _chatHub.Clients.User(_user.Id).SendAsync("OnMessageReceivedFromAssistant", json);
|
await _chatHub.Clients.User(_user.Id).SendAsync("OnMessageReceivedFromAssistant", json);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue