Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to translate "Scripted Response" in Virtual Agent?

Junyu
Tera Contributor

Dear all,

 

I am following the doc. to translate for Virtual Agent:

https://community.servicenow.com/community?id=community_article&sys_id=e134c27c1b773c50b09633f2cd4bcbde

 

But I found that it doesn't work for "Scripted Response" (in Virtual Agent -> Languages -> Translations, it doesn't show "Scripted Response" so I can't edit (translate) it).

find_real_file.png

How can I translate the script response?

12 REPLIES 12

nilimadesai
ServiceNow Employee
ServiceNow Employee

Hi Junyu, 

Scripted responses need to be wrapped in gs.getMessageLang() API as per the commented-out code in your screenshot above. 

You can also refer to this community article Return a message in a specific language, gs.getMessageLang() for more information on how to implement this. 

If I have answered your question, please mark my response as correct and/or helpful.

Regards,

Nilima 

Hi @nilimadesai ,

 

Thanks for your reply,

Now I'm confused about is: how do the system know that I switched a certain language?

For example,

When you go to a portal and switch the language in your profile:

find_real_file.png

Then how do you write a script to get this language id?

I followed the doc. you shared with me:

var language = current.assigned_to.preferred_language;

But this occurred "technical issue" in Virtual Agent, 

Could you write a simple demo for me to see how it works?

Thanks a lot.

Hi there,

Can you share in detail your updated code?

You could try using:

vaContext.getRequesterLang()

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi @Mark Roethof ,

Here is my script:

(function execute() {
    var tmp = vaInputs.fourth_choice_decision3.getDefaultDisplayValue();
    var language = current.assigned_to.preferred_language;
    
    return gs.getMessageLang('We only have: \" {0} \" as your next decision, please click \"Yes\" to continue.', language, [tmp]);
})()

 

I don't know how to edit it with "vaContext.getRequesterLang()". 

Can you show me a demo or tutorial for me?

Thank you.