Teams Integration : Work notes are displaying html text of transcript instead of normal text
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 11:27 PM
Hi Team,
After teams integration, I saw that the transcript of chats are automatically added to work notes in product documentation. But I am having an issue that the work notes contain the html script of transcript rather than the original text. What might have been the reason for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 11:42 PM
Hi @Neeraja2
This could be due to how the integration between ServiceNow and Microsoft Teams is configured and how data is being transferred between the two platforms.
Try to implement below script in ServiceNow to sanitize or strip HTML tags from incoming messages before saving them. Below is an example of a script that can be used for this purpose.
Assuming that you are working with a ServiceNow Scripted REST API or a Business Rule that processes incoming messages from Microsoft Teams. You can customize it based on your specific integration setup.
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
try {
var requestBody = request.body; // Assuming request contains the message content
var sanitizedMessage = stripHTMLTags(requestBody); // Sanitize HTML tags
// Now, save the sanitized message in the Work Notes field
var incidentGr = new GlideRecord('incident'); // Replace 'incident' with your table name
incidentGr.get(request.params.incident_id); // Assuming you pass the incident ID in the request
// Append the sanitized message to existing Work Notes or create a new Work Note
var workNotes = incidentGr.work_notes.getJournalEntry(1); // Get the existing Work Notes
var newWorkNote = 'Microsoft Teams Message:\n' + sanitizedMessage; // Customize the format
workNotes += '\n' + newWorkNote;
incidentGr.work_notes = workNotes;
// Save the incident record with the updated Work Notes
incidentGr.update();
response.setStatus(200);
response.setBody('Message processed successfully.');
} catch (ex) {
response.setStatus(500);
response.setBody('Error processing the message: ' + ex.getMessage());
}
})(request, response);
// Function to strip HTML tags from a string
function stripHTMLTags(input) {
return input.replace(/<[^>]*>?/gm, '');
}
Hope this info helps you.