How to translate "Scripted Response" in Virtual Agent?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2022 07:25 PM
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).
How can I translate the script response?
- Labels:
-
Virtual Agent

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2022 09:06 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2022 03:12 AM
Hi
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:
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2022 03:46 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2022 07:14 PM
Hi
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.