dịchTin nhắn

Bán hàng đa kênh cho Customer Service cung cấp một bộ chức năng mở rộng sức mạnh của Dynamics 365 Customer Service Enterprise để cho phép các tổ chức kết nối và tương tác ngay lập tức với khách hàng của họ trên các kênh nhắn tin kỹ thuật số. Cần có giấy phép bổ sung để truy cập Bán hàng đa kênh cho Customer Service. Để biết thêm thông tin, hãy xem trang tổng quan về giá Dynamics 365 Customer Service và kế hoạch định giá Dynamics 365 Customer Service .

Phương pháp này bắt buộc phải được thực hiện trong tài nguyên web. Phương pháp này được gọi cho mọi tin nhắn hội thoại được trao đổi giữa khách hàng và tổng đài viên, nếu bản dịch được bật và nếu tin nhắn chưa được dịch trước đó trong cuộc hội thoại cho ngôn ngữ đích.

Quan trọng

Xem tài nguyên web mẫu này để biết thêm thông tin về cách triển khai translateMessage API.

Cú pháp

function (conversationId, translationConfig): Object

Thông số

Tên Type Mô tả
translationConfig Đối tượng JavaScript Bao gồm các conversationIdcặp , và messagePayload khóa-giá translateToC1orC2 trị.

Đây là cấu trúc của translationConfig tham số.


export class UserType { 
        public static readonly C1 = "Agent"; //Used if the sender of the message is agent
        public static readonly C2 = "Customer"; //Used if the sender of the message is customer
        public static readonly CONSULT = "Consult Agent"; //Used if the sender of the message is other than agent or customer
} 
 
export class TranslateTo { 
        public static readonly C1 = "Agent"; //Used if message is translated for agent
        public static readonly C2 = "Customer"; //Used if message is translated for customer
} 
 
export class MessageContentType { 
        public static readonly Text = "Text"; //Used if the content type is text
} 
     
interface Sender { 
        userType: UserType;  //Points to any static field in UserType type,Represents the type of the user who is sending this message
} 

interface MessagePayload { 
        content: string;                 //Contains the content to be translated
        contentType: MessageContentType;  //Points to any static field in MessageContentType type,Represents the type of message content. For example: "Text" etc.
        sender: Sender; //Implements Sender interface, Represents the sender of the message
} 

interface translationConfig { 
        conversationId: string;   //Unique Id for conversation in Omnichannel for Customer Service
        messagePayload: MessagePayload;  //Implements MessagePayload interface, Represents the payload for the message to be translated
        translateToC1orC2: TranslateTo;   //Points to any static field in TranslateTo type,Represents for whom the message has to be translated 
 } 

Đây là một mẫu của conversationConfig tham số.

translationConfig = {
  "conversationId": "2b330c52-6844-4d36-8e05-03c78c9681dc",
  "messagePayload": {
    "content": "Hello",
    "contentType": "Text",
    "sender": {
      "userType": "Agent"
    }
  },
  "translateToC1orC2": "Customer"
}

Giá trị trả về

Trả về một promise phân giải thành một giao diện thực hiện đối TranslatedMessageResponse tượng JavaScript.

Đối tượng giao diện

export interface ErrorObject{ 
        isError: boolean; //mandatory field, represents true for error while executing this function else no
        errorCode: ErrorCodes; //mandatory field, represents the type of error based on errorCode
} 

export interface TranslatedMessageResponse { 
        translatedMessage: string;  //mandatory field, Contains the translated message
        sourceLanguage: string;       //mandatory field, represents the language locale of the original content 
        destinationLanguage: string;  //mandatory field, represents the language locale of the translated content
        errorObject?: ErrorObject;  //optional field, represents the error object for any error scenarios
}

Tham errorCode số in ErrorObject chỉ đại diện cho các lỗi từ danh sách sau.

Thông báo lỗi Mã lỗi Mô tả
MESSAGE_TOO_LONG 100 Mã lỗi cho tin nhắn rất dài mà dịch vụ dịch thuật không dịch được
LANGUAGE_NOT_SUPPORTED 101 Mã lỗi cho ngôn ngữ không được dịch vụ dịch thuật hỗ trợ
MESSAGE_NOT_TRANSLATED 102 Mã lỗi cho tin nhắn không được dịch bởi dịch vụ dịch thuật
TRANSLATION_SERVICE_LIMIT_EXCEEDED 103 Mã lỗi nếu vượt quá giới hạn hạn ngạch cho dịch vụ dịch thuật
TRANSLATION_FAILED 104 Mã lỗi nếu dịch vụ dịch không dịch được tin nhắn
UNRECOGNIZED_TEXT 105 Mã lỗi nếu văn bản không được dịch vụ dịch thuật nhận dạng
UNRECOGNIZED_ERROR 200 Mã lỗi nếu có bất kỳ lỗi nào khác với lỗi được liệt kê.

sourceLanguage Tham số và trong destinationLanguageTranslatedMessageResponse giao diện đại diện cho ID Locale. Thông tin thêm: ID ngôn ngữ.

Phản hồi mẫu

{
  "translatedMessage": "Hola",
  "destinationLanguage": "3082",
  "errorObject": {
    "isError": false,                             
    "errorCode": null
  },
  "sourceLanguage": "3082"
}

Lưu ý

  • Trong trường hợp có ngoại lệ trong quá trình thực thi phương pháp này, Bán hàng đa kênh cho Customer Service sẽ không thử lại và thay vào đó sẽ hiển thị thông báo lỗi dịch không thành công.
  • Lỗi trong khi thực hiện phương thức này có thể được thông báo qua .errorObject Trong trường hợp xảy ra lỗi, Bán hàng đa kênh cho Customer Service sẽ không thử lại và thay vào đó sẽ hiển thị thông báo lỗi dựa trên mã lỗi được cung cấp.
  • Trong trường hợp phản hồi trả về không hợp lệ hoặc không đầy đủ, thông báo lỗi trên biểu ngữ dịch sẽ xuất hiện trong điều khiển cuộc hội thoại.
  • Nếu phương pháp này không được triển khai, thì thông báo sẽ không được dịch và thông báo lỗi sau sẽ được hiển thị cho tổng đài viên.

thông báo lỗi translateMessage.

Thêm tài nguyên web để dịch theo thời gian thực