translateMessage

La Plataforma omnicanal per al Customer Service ofereix un conjunt de capacitats que amplien el potencial del Dynamics 365 Customer Service Enterprise per permetre a les organitzacions connectar-se i interactuar de manera immediata amb els seus clients a través de canals de missatgeria digital. Cal una llicència addicional per accedir a la Plataforma omnicanal per al Customer Service. Per obtenir més informació, vegeu les pàgines Informació general del Dynamics 365 Customer Service i Pla de preus del Dynamics 365 Customer Service .

Aquest mètode s'ha d'implementar al recurs web. Aquest mètode es crida per a cada missatge de conversa intercanviat entre el client i l'agent, si la traducció està activada i si el missatge no s'ha traduït abans de la conversa per a l'idioma de destinació.

Important

Vegeu aquest recurs web d'exemple per obtenir més informació sobre com implementar l'API translateMessage .

Sintaxi

function (conversationId, translationConfig): Object

Paràmetres

Nom Type Descripció
translationConfig Objecte JavaScript Consta de conversationIdparells i messagePayloadtranslateToC1orC2 parells clau-valor.

Aquí teniu l'estructura del translationConfig paràmetre.


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 
 } 

Aquí teniu una mostra del conversationConfig paràmetre.

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

Valor retornat

Retorna una promesa que es resol a una interfície d'implementació TranslatedMessageResponse d'objectes JavaScript.

Objecte de la interfície

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
}

El errorCode paràmetre in ErrorObject representa només els errors de la llista següent.

Missatge d'error Codi d'error Descripció
MESSAGE_TOO_LONG 100 Codi d'error per a missatges molt llargs que el servei de traducció no pot traduir
LANGUAGE_NOT_SUPPORTED 101 Codi d'error per a l'idioma no admès pel servei de traducció
MESSAGE_NOT_TRANSLATED 102 Codi d'error del missatge no traduït pel servei de traducció
TRANSLATION_SERVICE_LIMIT_EXCEEDED 103 Codi d'error si s'ha superat el límit de quota per al servei de traducció
TRANSLATION_FAILED 104 Codi d'error si el servei de traducció no ha pogut traduir un missatge
UNRECOGNIZED_TEXT 105 Codi d'error si el servei de traducció no reconeix el text
UNRECOGNIZED_ERROR 200 Codi d'error si hi ha algun error diferent de l'indicat.

El sourceLanguage paràmetre and destinationLanguage de la TranslatedMessageResponse interfície representa un identificador de configuració regional. Més informació: Identificador de configuració regional.

Exemple de resposta

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

Nota

  • En cas d'excepció durant l'execució d'aquest mètode, l'Omnicanal per al Customer Service no ho tornarà a intentar i mostrarà un missatge d'error de traducció fallida.
  • L'error en executar aquest mètode es pot notificar a través de errorObject. En cas d'error, l'Omnicanal per al servei d'atenció al client no ho tornarà a intentar i mostrarà el missatge d'error basat en els codis d'error proporcionats.
  • En cas que la resposta retornada no sigui vàlida o incompleta, apareixerà un missatge d'error al bàner de traducció al control de conversa.
  • Si no s'implementa aquest mètode, el missatge no es traduirà i es mostrarà el següent missatge d'error a l'agent.

translateMessage d'error.

Afegir un recurs web per a la traducció en temps real