voice copilot support postback
voice copilot support postback
This commit is contained in:
parent
e9194b8247
commit
effe494571
|
|
@ -67,10 +67,10 @@ namespace BotSharp.Plugin.Twilio.Services
|
|||
var progressService = sp.GetRequiredService<IConversationProgressService>();
|
||||
InitProgressService(message, sessionManager, progressService);
|
||||
InitConversation(message, inputMsg, conv, routing);
|
||||
|
||||
|
||||
var result = await conv.SendMessage(config.AgentId,
|
||||
inputMsg,
|
||||
replyMessage: null,
|
||||
replyMessage: BuildPostbackMessageModel(conv),
|
||||
async msg =>
|
||||
{
|
||||
reply = new AssistantMessage()
|
||||
|
|
@ -88,6 +88,20 @@ namespace BotSharp.Plugin.Twilio.Services
|
|||
await sessionManager.SetAssistantReplyAsync(message.ConversationId, message.SeqNumber, reply);
|
||||
}
|
||||
|
||||
private PostbackMessageModel BuildPostbackMessageModel(IConversationService conv)
|
||||
{
|
||||
var messages = conv.GetDialogHistory(1);
|
||||
if (!messages.Any()) return null;
|
||||
var lastMessage = messages[0];
|
||||
if (string.IsNullOrEmpty(lastMessage.PostbackFunctionName)) return null;
|
||||
return new PostbackMessageModel
|
||||
{
|
||||
FunctionName = lastMessage.PostbackFunctionName,
|
||||
ParentId = lastMessage.MessageId,
|
||||
Payload = lastMessage.Payload
|
||||
};
|
||||
}
|
||||
|
||||
private static void InitConversation(CallerMessage message, RoleDialogModel inputMsg, IConversationService conv, IRoutingService routing)
|
||||
{
|
||||
routing.Context.SetMessageId(message.ConversationId, inputMsg.MessageId);
|
||||
|
|
|
|||
Loading…
Reference in a new issue