Udostępnij za pośrednictwem


translateMessage

Aplikacja Obsługa wielokanałowa klientów dla Dynamics 365 oferuje zestaw funkcji, które rozszerzają możliwości Dynamics 365 Customer Service Enterprise, aby umożliwić organizacjom natychmiastowe łączenie się i interakcję z klientami za pośrednictwem cyfrowych kanałów komunikacji. Do uzyskania dostępu do plików sieciOwych w celu obsługa klienta jest wymagana dodatkowa licencja. Aby uzyskać więcej informacji, zobacz omówienie cennika usługi Dynamics 365 Customer Service i strony cennika Dynamics 365 Customer Service.

Ta metoda jest wymagana do zaimplementowania w zasobie internetowym. Ta metoda jest wywoływana dla każdej wiadomości konwersacji wymienianej między klientem a agentem, jeśli tłumaczenie jest włączone i jeśli wiadomość nie została przetłumaczona wcześniej w konwersacji dla języka docelowego.

Ważne

Zobacz ten przykładowy zasób internetowy , aby uzyskać więcej informacji na temat implementowania translateMessage interfejsu API.

Składnia

function (conversationId, translationConfig): Object

Parametry

Name Typ Description
translationConfig Obiekt JavaScript Składa się z conversationIdpar , messagePayload i translateToC1orC2 klucz-wartość.

Oto struktura translationConfig parametru.


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 
 } 

Oto przykładowy parametr.conversationConfig

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

Wartość zwracana

Zwraca obietnicę, która jest rozpoznawana jako interfejs implementujący TranslatedMessageResponse obiekt JavaScript.

Obiekt interfejsu

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
}

Parametr errorCode in ErrorObject reprezentuje błędy tylko z poniższej listy.

Komunikat o błędzie Kod błędu Description
MESSAGE_TOO_LONG 100 Kod błędu dla bardzo długiej wiadomości, której usługa tłumaczenia nie może przetłumaczyć
LANGUAGE_NOT_SUPPORTED 101 Kod błędu dla języka, który nie jest obsługiwany przez usługę tłumaczenia
MESSAGE_NOT_TRANSLATED 102 Kod błędu dla wiadomości, która nie została przetłumaczona przez usługę tłumaczenia
TRANSLATION_SERVICE_LIMIT_EXCEEDED 103 Kod błędu w przypadku przekroczenia limitu przydziału dla usługi tłumaczeniowej
TRANSLATION_FAILED 104 Kod błędu, jeśli usługa tłumaczenia nie może przetłumaczyć komunikatu
UNRECOGNIZED_TEXT 105 Kod błędu, jeśli tekst nie jest rozpoznawany przez usługę tłumaczenia
UNRECOGNIZED_ERROR 200 Kod błędu, jeśli wystąpił błąd inny niż wymieniony.

Parametr sourceLanguage and destinationLanguage w TranslatedMessageResponse interfejsie reprezentuje identyfikator ustawień regionalnych. Więcej informacji: Identyfikator ustawień regionalnych.

Przykładowa odpowiedź

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

Uwaga / Notatka

  • W przypadku wyjątku podczas wykonywania tej metody, aplikacja Obsługa wielokanałowa dla Customer Service nie ponowi próby, a zamiast tego wyświetli komunikat o błędzie z nieudanym tłumaczeniem.
  • Błąd podczas wykonywania tej metody można powiadomić za pomocą errorObject. W przypadku wystąpienia błędu, aplikacja Obsługa wielokanałowa dla Customer Service nie ponowi próby, a zamiast tego wyświetli komunikat o błędzie na podstawie podanych kodów błędów.
  • W przypadku, gdy zwrócona odpowiedź jest nieprawidłowa lub niekompletna, w kontrolce konwersacji pojawi się komunikat o błędzie na banerze tłumaczenia.
  • Jeśli ta metoda nie zostanie zaimplementowana, komunikat nie zostanie przetłumaczony, a następujący komunikat o błędzie zostanie wyświetlony agentowi.

Komunikat o błędzie translateMessage.

Dodawanie zasobu internetowego do tłumaczenia w czasie rzeczywistym