Dynamics 365 Contact Center의 컨텍스트 메시지는 이벤트 활동으로 AI 에이전트에게 전송됩니다. 고객 정보, 라이브 작업 항목 또는 대화 ID와 같은 컨텍스트 정보는 활동 JSON의 일부로 에이전트에게 전송됩니다. JSON은 대부분의 채널에 대해 startConversation 형식이고 음성 대화에 대해 ConversationUpdate 형식일 수 있습니다.
에이전트 코드에서 에이전트에 대한 컨텍스트 가져오기 및 사용
이러한 컨텍스트 메시지를 처리하려면 활동 처리기를 사용하고 에이전트 코드에서 재정의합니다. 활동 처리기를 사용하는 방법에 대한 자세한 내용은 활동 처리기를 사용하는 이벤트 기반 대화를 참조하세요.
다음 예제에서는 이벤트 활동이 수신 OnEventActivityAsync 되면 컨텍스트를 가져오고 사용하기 위해 메서드가 호출됩니다.
namespace Microsoft.CCaaS.MessagingRuntime.TestAgent.Agents;
public class TestAgentApplication : AgentApplication
{
private readonly IContextManager _contextManager;
public TestAgentApplication(AgentApplicationOptions options, IContextManager contextManager) : base(options)
{
_contextManager = contextManager ?? throw new ArgumentNullException(nameof(contextManager));
OnConversationUpdate(ConversationUpdateEvents.MembersAdded, OnMembersAddedAsync);
OnEvent(ActivityTypes.Event, OnEventActivityAsync);
OnActivity(ActivityTypes.Message, OnMessageActivityAsync, rank: RouteRank.Last);
}
protected async Task OnMessageActivityAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(turnContext);
var text = turnContext.Activity.Text?.ToLower(CultureInfo.InvariantCulture);
var responseActivity = Activity.CreateMessageActivity();
Responses.BuildCustomerFileAttachmentResponse(turnContext, responseActivity);
}
}