Đặt cấu hình ngữ cảnh tổng đài viên trong tổng đài viên Azure

Lưu ý

Copilot Studio bot được đổi tên thành Copilot agent (tác nhân hoặc tác nhân AI). Nhân viên đại diện con người hiện được đổi tên thành đại diện dịch vụ khách hàng (service representative hoặc representator). Bạn có thể bắt gặp các tham chiếu đến các thuật ngữ cũ và mới khi chúng tôi cập nhật giao diện người dùng, tài liệu và nội dung đào tạo của sản phẩm.

Đối với tổng đài viên Azure, bạn phải cài đặt SDK tổng đài viên và khởi tạo phần mềm trung gian Bán hàng đa kênh trước khi đặt cấu hình ngữ cảnh tổng đài viên.

Cài đặt SDK bot trong dự án của bạn

  1. Để mở Package Manager NuGet, nhấp chuột phải vào dự án của bạn và sau đó chọn Quản lý gói NuGet.

  2. Trong Package Manager NuGet, chọn nguồn gói là nuget.org và duyệt "Microsoft.Dynamics. AgentsSDK.Middleware" (bằng tiếng Anh). Chọn gói, sau đó chọn Cài đặt. Tìm hiểu thêm trong trang Nuget.

    Ngoài ra, bạn có thể sử dụng lệnh sau trong NuGet CLI.

    Install-Package Microsoft.Dynamics.AgentsSDK.Middleware
    

SDK tác nhân hiện đã được cài đặt và phần mềm trung gian Bán hàng đa kênh có sẵn trong dự án của bạn.

Sử dụng phần mềm trung gian Bán hàng đa kênh trong mã tổng đài viên của bạn

  1. Mở tệp AdapterWithErrorHandler.cs .

  2. Thêm câu lệnh nhập và khởi tạo phần mềm trung gian Bán hàng đa kênh.

    using Microsoft.Dynamics.AgentsSDK.Middleware.Core; 
    Use(new OmnichannelMiddleware()); 
    
    using System.Globalization;
    using System.Text;
    using Microsoft.Agents.Connector;
    using Microsoft.Agents.Core;
    using Microsoft.Agents.Core.Errors;
    using Microsoft.Extensions.Logging;
    using Microsoft.Dynamics.AgentsSDK.Middleware.Core;
    
    namespace Microsoft.CCaaS.MessagingRuntime.TestAgent;
    
    public class AdapterWithErrorHandler : CloudAdapter
    {
        public AdapterWithErrorHandler(
            IChannelServiceClientFactory channelServiceClientFactory,
            IActivityTaskQueue activityTaskQueue,
            ILogger<CloudAdapter> logger)
            : base(channelServiceClientFactory, activityTaskQueue, logger)
        {
            // OmnichannelMiddleware has special handling for OC event messages
            Use(new OmnichannelMiddleware());
    
            OnTurnError = async (turnContext, exception) =>
            {
                var exceptionInfo = GetExceptionInfo(exception);
                logger.LogAppException(exceptionInfo, exception);
    
                // Send a message to the user
                await turnContext.SendActivityAsync($"The bot encountered an error or bug.{Environment.NewLine}{exceptionInfo}");
                await turnContext.SendActivityAsync("To continue to run this bot, please fix the bot source code.");
    
                // Send a trace activity, which will be displayed in the Bot Framework Emulator
                await turnContext.TraceActivityAsync("OnTurnError Trace", exception.Message, "https://www.botframework.com/schemas/error", "TurnError");
            };
        }
    
        private static string GetExceptionInfo(Exception exception)
        {
            var sb = new StringBuilder();
    
            // Pull some well known info from ErrorResponse.Exception if available.
            if (exception is ErrorResponseException responseException)
            {
                sb.AppendLine(CultureInfo.InvariantCulture, $"Error code: {responseException.Body?.Error?.Code ?? "NA"}");
                sb.AppendLine(CultureInfo.InvariantCulture, $"Error message: {responseException.Body?.Error?.Message ?? "NA"}");
            }
    
            sb.AppendLine(CultureInfo.InvariantCulture, $"Exception message: {exception.Message}");
            sb.AppendLine();
            sb.AppendLine(exception.ToString());
    
            var exceptionInfo = sb.ToString();
            return exceptionInfo;
        }
    }
    

Các bước tiếp theo

Phân tích cú pháp JSON hoạt động để lấy ngữ cảnh tác nhân

Gửi ngữ cảnh tùy chỉnh
thiết lập Nhà cung cấp ngữ cảnh
Tích hợp một tác nhân Azure