Connect chat - How to inject CLICKABLE links trough connect action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2017 05:37 AM
Hi,
i ´ve been trying for a few days to inject a link on the connect chat by using a connect action that i have created. The goal is to send the chat survey link on the chat once it is closed.
1st i have tried generating a simple html string, and successfully injected the link on the chat, but the link was not clickable, it was just a normal text. Below is the snippet of my attempt:
var gcm = new GlideCollaborationManager();
gcm.sendSystemMessage(sys_id, surveyLink)
The ONLY way that i have found to do this, after researching a lot, is by using the "SNC.LiveFeedApi()". I am able to inject the clickable link in the chat this way, BUT, once you click the link, it is rendered inside ServiceNow backend UI, instead of service portal. I don ´t have any control over the generated link, it seems to be generating correctly but once you click the link, it adds "nav_to.do?uri=/" to the url, causing the link to be rendered inside SN backend UI.
*NOTE: as per Hi support, GlideCollaborationManager() and SNC.LiveFeedAPI() are not public, so there is no documentation available.
Below is the complete code inside my connect action:
/* Get chat Survey Link for the customer */
// The survey is only triggered when the chat is completed
gs.sleep(2000); // timer for the survey generation
// Pulling the survey record, to get it ´s link
var gcm = new GlideCollaborationManager();
var grSurveyInstance = new GlideRecord("asmt_assessment_instance");
var surveyLink = "";
var hrPortalURL = "hrportal?id=take_survey&instance_id=";
var message = "Help us improve by taking our short satisfaction survey related to your recent chat request!";
grSurveyInstance.addQuery("task_id", conversation.queueEntry.sys_id);
grSurveyInstance.query();
// Setting up the user ´s survey instance URL
if(grSurveyInstance.next()){
surveyLink =gs.getProperty('glide.servlet.uri') + hrPortalURL + grSurveyInstance.sys_id;
var id = conversation.document.group;
new SNC.LiveFeedApi().addMessage(message + "\n\n\n" + surveyLink, id);
}
Do anyone know how can i make the link render correctly in any other way?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2017 04:48 PM
Hi Mohan,
You can achieve #3 via BR.
Use chat_queue_entry as table.
Set action == accepted and state.changesTo('Closed Complete') as your condition.
Then on the script you can query the current chat and base it on document_id.
Sample
if(current.document_id.nil())
state = 3 //return the chat back to Waiting in Progress
current.update();
You can customize this further by adding a message like "Chat will remain open until an INC is created".
You can do that by inserting the message via the live_message table.
-Carl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 04:26 AM
Hi Carl,
Thanks for response. When I checked the chat_queue_entry for the existing chat entries, document Id seems to be empty for all and error message is throwing for all sessions when closed but this code is allowing the chat to end and not aborting action.Let me know, how we can find the ticket not created through particular chat window.Also, i used the below code and before insert/update condition used.
if(current.document_id.nil())
{
state = 3 ;//return the chat back to Waiting in Progress
gs.addErrorMessage("Chat will remain open until an INC is created" );
current.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 04:48 AM
update:
Since we are using customized code to create incidents and not using response.new record the document ID and document table are not populating. Can you please help me on the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 04:28 PM
Hi Mohan,
How do you create INC then? If the document_id field is not being populated then may I recommend adding the following:
current.document_table ='incident';
current.document_id = <incident sys_id>
current.update();
Do note that you have to add the code above via your chat INC creation script and update the chat_queue_entry table. That way, you will be able to add the document id to the table and the
business rule to check for chat w/o tickets.
Regards,
Carl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2017 09:50 AM
i have tried using the below snippet in different sections but am unable to update the doc fields. Can you please take a look.
//updating the docuemnt fields
var ch = new GlideRecord('chat_queue_entry');
ch.addQuery('queue', current.queue);
ch.query();
if (ch.next()) {
ch.document_table ='incident';
ch.document_id = 'Incident:' +item.number;
ch.update();
}
Exact Script:
var inc = new GlideRecord("incident");
inc.initialize();
inc.caller_id = conversation.document.opened_by;
inc.short_description = conversation.document.short_description;
inc.contact_type = 'Chat';
inc.work_notes = desc;
inc.insert();
var id = conversation.document.sys_id;
var gr = new GlideRecord('live_group_profile');
gr.addQuery('document',id);
gr.query();
if(gr.next())
{
var item = new GlideRecord('incident');
item.addQuery('sys_id', inc.sys_id);
item.query();
if (item.next()) {
var msg = new GlideRecord('live_message');
msg.initialize();
msg.sys_created_by = conversation.document.opened_by.user_name;
msg.group = gr.sys_id;
msg.profile = gs.getUserID();
msg.Chat = true ;
msg.message = 'Incident ' + item.number ;
inc.work_notes = "Chat ID is: " + conversation.document.number ;
nc.update();
var id = conversation.document.group;
new SNC.LiveFeedApi().addMessage( msg.message, id);
//updating the docuemnt fields
var ch = new GlideRecord('chat_queue_entry');
ch.addQuery('queue', current.queue);
ch.query();
if (ch.next()) {
ch.document_table ='incident';
ch.document_id = 'Incident:' +item.number;
ch.update();
}
}}