共用方式為


剖解析事件活動 JSON 以取得客服專員內容

Dynamics 365 聯絡中心中的上下文訊息會以事件活動形式傳送給 AI 代理。 客戶資訊、即時工作專案或交談標識碼等內容資訊會作為活動 JSON 的一部分傳送給客服專員。 JSON 類型可以是大部分通道的 startConversation ,而語音交談的 JSON 類型可以是 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);
    }
}

後續步驟

剖解析活動 JSON 的程式碼範例

setContextProvider
整合 Azure 代理程式