Merge pull request #354 from iceljc/features/fulfill-redirect-to-agent
add redirect to agent
This commit is contained in:
commit
483eb5c1d3
|
|
@ -1,3 +1,5 @@
|
|||
using BotSharp.Abstraction.Messaging.Enums;
|
||||
|
||||
namespace BotSharp.Abstraction.Messaging;
|
||||
|
||||
public interface IRichMessage
|
||||
|
|
@ -6,5 +8,5 @@ public interface IRichMessage
|
|||
string Text { get; set; }
|
||||
|
||||
[JsonPropertyName("rich_type")]
|
||||
string RichType => "text";
|
||||
string RichType => RichTypeEnum.Text;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ public class RoutingRule
|
|||
public bool Required { get; set; }
|
||||
|
||||
public string? RedirectTo { get; set; }
|
||||
public string? RedirectToAgentName { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,23 @@ public class AgentController : ControllerBase
|
|||
{
|
||||
AgentIds = new List<string> { id }
|
||||
});
|
||||
return agents.Items.FirstOrDefault();
|
||||
|
||||
var targetAgent = agents.Items.FirstOrDefault();
|
||||
var redirectAgentIds = targetAgent.RoutingRules
|
||||
.Where(x => !string.IsNullOrEmpty(x.RedirectTo))
|
||||
.Select(x => x.RedirectTo).ToList();
|
||||
var redirectAgents = await _agentService.GetAgents(new AgentFilter
|
||||
{
|
||||
AgentIds = redirectAgentIds
|
||||
});
|
||||
foreach (var rule in targetAgent.RoutingRules)
|
||||
{
|
||||
var found = redirectAgents.Items.FirstOrDefault(x => x.Id == rule.RedirectTo);
|
||||
if (found == null) continue;
|
||||
|
||||
rule.RedirectToAgentName = found.Name;
|
||||
}
|
||||
return targetAgent;
|
||||
}
|
||||
|
||||
[HttpGet("/agents")]
|
||||
|
|
|
|||
Loading…
Reference in a new issue