Language translation using flow designer | Dynamic translation spoke | sample use-case | ServiceNow
hi everyone in my previous videos i have given an overview of dynamic translation and how we can achieve dynamic translation or language translation using scripts which again are using dynamic translation api and in this video i am going to show you how we can do the same using dynamic translation spoke which is available out of the box when we install dynamic translation plugin so this is an incident record which is not created yet let me select a caller and select a particular text if i save this ticket this is just to make sure that translation is not happening via the scripts because i have already disabled those scripts in the backend if i go to the translation tab there is no language detected there's no short description which is translated so now how can we make the translation happen using this book is that i am going to jump to the designer let's create a new flow insert let this be the name of my flow i'm going to change this to system user and let's submit this record so i want to detect the language only when the record is inserted so for that let's just add a trigger my interview is when the record is created which means when an incident record is created then only this flow is going to execute this is the incident table advanced options yes yes yes yes everything looks okay done add an action let's say if condition if my short description is not empty then only it translates the text and detects the language short description where it is drag and drop short description is not blank this is the condition inside this if now i am going to add an action dynamic translation here i can use the detect language to detect the language of a particular text the text is mentioned again in my short description feed so i'm going to do a diagram again and translator is microsoft so in this part my language will be detected and if i have to translate the text to my desired language then i need to add another action over here again i am look for dynamic translation come on translate text text to translate is within my short description field again target language is english i want to convert whatever text is written over there in the english language my translator is microsoft and if i want i can add multiple target languages over here by clicking on this plus icon but for now i only want this in english so this part is also complete so once language is detected my text is converted now i want to update this back to my incident record in the translation tab which i have already shown you there are two fields one is ticket language and the second one is short description translated so i'm going to add an action over here to update the record we have to record so the code is my incident record let's drag and drop cylinder called over here table is auto populated so first field which i want to auto populate is my ticket language field and the second would be short description to populate the ticket language so ticket language field is of type reference see over here so i cannot simply drag and drop the response received from the data pill in the detect language because it is in the form of strength and also the data pills towards the right side are disabled so dragon top in any case would not work even if even if the field ticket language would have been in string format so i will have to write a custom script to make it work okay so let's jump to the script part so i am getting the language from this detected language which is the second part of the database so i can simply language code equals to dot second is detect language and then again dot detector underscore language code okay so here i have the language code i just need to get this id of this language code for which i have already written a function which i demonstrated in my previous video let me show it to you again so i will have this is my script include here i have already written a function which returns the society of the language you are so this is the function get language society i just need to call this function so i hope you guys are already aware how to call so languages id equals to me then the name of my script include dot then i'm going to mention the name of the function and then i am going to pass the language code and i can simply return the language society from here and it will set my ticket language okay so this part is done and the second field which i want to set is the short description field short description translated again as i mentioned the data pills are already disabled so i won't be able to drag and drop the translated text from here let's try it doesn't work so again i will have to use couple of scripts to achieve what i want to achieve now let's see how we can do that so this particular object translate text object is actually an array of the multiple languages which we want to convert our data into as i already mentioned that i can pass multiple languages in the translate text action by clicking on plus icon so that is the reason this is an array which returns responses for all those languages all the translated text that is why i need to set it in that form [Music] again this is going to be ft underscore data dot translate text and then the name of my object as in this case is translations then i can simply get the translated text over here since my target language is only english i will contain only one data so to get the single element of the array i need to pass 0 over here then i can use the translated text and i can simply return my translated short description now let's click on done and save this flow flow saved successfully and let's activate this flow as well flow activated successfully there was no error while activating the flow now go back to the incident and create a new incident [Music] let's copy this text paste it over here and save this record now in the translations tab based on whatever short description i have mentioned here the detected language should be populating whatever this language is and the conversion of this text should also be visible so let's click here and see what is the meaning of this text and now navigate to the translations tab language is populated and the conversion is populated you can see it's the same so this is how we can achieve the same using the dynamic translation spoke there is one more thing which i want to show you how i have got the object names over here like for example if i talk about this one detected language because if you take a look at the response it is something like this and it is not detected under school language it is detected language so this i'll have taken a look at the flow that's executed in the back end okay let us open this in operations view if you know if you're not able to see operations view in your instance then you need to activate a system property which you can easily look into the service docs so let's go to the translate text and if i click on the detected language so here you can see that i am taking a look at the detected underscore language object not the detected language so when we use it via the dynamic translation api scripts then we make use of detected language when we are writing a script in the dynamic translation spoke in the flow designer so we use detected underscore language so that's the difference and that's where you come to know which object you need to use to get the value of the language or to get the value of the translated text if i take a look at here you can easily see that it is an array of objects and the name of the objective translations so this is pretty much it and this is how we can achieve language detection or the translation of the language using dynamic translation spoke which is available out of the box as part of the dynamic translation plugin thank you for watching and don't forget to subscribe
https://www.youtube.com/watch?v=oBicaH8EPkQ