Sdílet prostřednictvím


translateMessage

Omnikanál pro Customer Service nabízí sadu funkcí, které rozšiřují výkon Dynamics 365 Customer Service Enterprise, což umožňuje organizacím okamžitě se spojit a komunikovat se svými zákazníky prostřednictvím kanálů digitálního zasílání zpráv. Pro přístup k Omnikanálu pro Customer Service je vyžadována další licence. Více informací naleznete na stránkách Přehled cen Dynamics 365 Customer Service a Cenový plán Dynamics 365 Customer Service.

Tato metoda musí být implementována ve webovém prostředku. Tato metoda se volá pro každou zprávu konverzace vyměňovanou mezi zákazníkem a agentem, pokud je překlad zapnutý a pokud zpráva nebyla přeložena dříve v konverzaci pro cílový jazyk.

Důležité

Další informace o tom, jak implementovat rozhraní API, najdete v tomto ukázkovém translateMessage.

Syntaxe

function (conversationId, translationConfig): Object

Parametry

Název Typ Description
translationConfig Objekt JavaScript Skládá se z conversationIdpárů klíč-hodnota messagePayload a translateToC1orC2 ,

Zde je struktura parametru 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 
 } 

Zde je ukázka parametru conversationConfig .

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

Návratová hodnota

Vrátí příslib, který se přeloží na implementační TranslatedMessageResponse rozhraní objektu JavaScript.

Objekt rozhraní

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 představuje pouze chyby z následujícího seznamu.

Zpráva o chybě Kód chyby Description
MESSAGE_TOO_LONG 100 Kód chyby pro velmi dlouhou zprávu, kterou překladatelská služba nemůže přeložit
LANGUAGE_NOT_SUPPORTED 101 Kód chyby pro jazyk, který překladová služba nepodporuje
MESSAGE_NOT_TRANSLATED 102 Kód chyby pro zprávu, která nebyla přeložena překladatelskou službou
TRANSLATION_SERVICE_LIMIT_EXCEEDED 103 Kód chyby, pokud byla překročena maximální kvóta pro překladatelskou službu
TRANSLATION_FAILED 104 Kód chyby, pokud se službě překladu nepodařilo přeložit zprávu
UNRECOGNIZED_TEXT 105 Kód chyby, pokud překladová služba text nerozpozná
UNRECOGNIZED_ERROR 200 Kód chyby, pokud dojde k jiné chybě než uvedené.

Parametr sourceLanguage and destinationLanguage v TranslatedMessageResponse rozhraní představuje ID národního prostředí. Další informace: ID národního prostředí.

Ukázková odpověď

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

Poznámka:

  • V případě výjimky během provádění této metody se Omnikanál pro Customer Service nebude opakovat a místo toho zobrazí chybovou zprávu o selhání překladu.
  • Na chybu při provádění této metody lze upozornit prostřednictvím errorObject. V případě chyby se Omnikanál pro Customer Service nebude opakovat a místo toho zobrazí chybovou zprávu na základě poskytnutých chybových kódů.
  • V případě, že je vrácená odpověď neplatná nebo neúplná, zobrazí se v ovládacím prvku konverzace chybová zpráva na banneru překladu.
  • Pokud tato metoda není implementována, zpráva nebude přeložena a agentovi se zobrazí následující chybová hláška.

chybová zpráva translateMessage.

Přidání webového zdroje pro překlad v reálném čase