перекласти Повідомлення

Омніканальність для Customer Service пропонує ряд можливостей, які розширюють можливості Dynamics 365 Customer Service Enterprise, що дає змогу організації миттєво підключатися і взаємодіяти з клієнтами через канали цифрових комунікацій. Для доступу до Омніканальності для Customer Service необхідна додаткова ліцензія. Додаткові відомості ви знайдете на сторінках Огляд цін на Dynamics 365 Customer Service і Цінові плани для Dynamics 365 Customer Service.

Цей метод є обов'язковим для реалізації на веб-ресурсі. Цей метод викликається для кожного повідомлення в розмові, яким обмінюються клієнт і агент, якщо переклад увімкнено і якщо повідомлення не було перекладено раніше в розмові для мови призначення.

Важливо

Перегляньте цей зразок веб-ресурсу для отримання додаткової інформації про те, як реалізувати translateMessage API.

Синтаксис

function (conversationId, translationConfig): Object

Параметри

Ім'я Type Опис
translationConfig Об'єкт JavaScript Складається з conversationIdпар , messagePayload і translateToC1orC2 ключ-значення.

Ось структура translationConfig параметра.


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 
 } 

Ось приклад параметра conversationConfig .

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

Значення, що повертається

Повертає проміс, який вирішується в інтерфейсі реалізації TranslatedMessageResponse об'єкта JavaScript.

Об'єкт інтерфейсу

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
}

Параметр errorCode in ErrorObject представляє помилки лише з наступного списку.

Повідомлення про помилку Код помилки Опис
MESSAGE_TOO_LONG 100 Код помилки дуже довгого повідомлення, яке служба перекладу не може перекласти
LANGUAGE_NOT_SUPPORTED 101 Код помилки для мови, яка не підтримується службою перекладу
MESSAGE_NOT_TRANSLATED 102 Код помилки повідомлення, яке не перекладено службою перекладу
TRANSLATION_SERVICE_LIMIT_EXCEEDED 103 Код помилки, якщо перевищено ліміт квоти для служби перекладу
TRANSLATION_FAILED 104 Код помилки, якщо службі перекладу не вдалося перекласти повідомлення
UNRECOGNIZED_TEXT 105 Код помилки, якщо текст не розпізнається службою перекладу
UNRECOGNIZED_ERROR 200 Код помилки, якщо є якась помилка, відмінна від зазначеної.

Параметр sourceLanguage and destinationLanguage в TranslatedMessageResponse інтерфейсі представляє ідентифікатор локалі. Додаткові відомості: Ідентифікатор локалі.

Зразок відповіді

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

Нотатка

  • У разі винятку під час виконання цього методу Omnichannel for Customer Service не повторюватиме спроби, а натомість відобразить повідомлення про помилку перекладу.
  • Про помилку під час виконання цього методу можна повідомити за допомогою errorObject. У разі помилки Omnichannel for Customer Service не повторюватиме спробу, а натомість відобразить повідомлення про помилку на основі наданих кодів помилок.
  • У разі, якщо повернута відповідь невірна або неповна, в елементі керування розмовою з'явиться повідомлення про помилку на банері перекладу.
  • Якщо цей метод не реалізовано, то повідомлення не буде перекладено, а агенту буде відображено наступне повідомлення про помилку.

повідомлення про помилку translateMessage.

Додайте веб-ресурс для перекладу в реальному часі