This automation will send an email to a configured email address or Role with a list of Forum Thread URLs that are unanswered in the Community after x number of hours.
Download for version 11:
<automations> <automations> <automation name="Unaswered Threads Notifications" version="11.1.8.16788" description="This sends an email with a list of thread urls that have not been answered after x number of hours." id="f624be8c283d479096e806444e857bb4" executeAsServiceUser="true" isSingleton="false" trigger="Job" schedule="5m" lastModified="2022-01-13 20:50:46Z"> <executionScript language="JavaScript"><![CDATA[var pageIndex = 0; var done = false; var unanswered = []; var hours = core_v2_widget.GetStringValue('hours', '18'); var subject = core_v2_widget.GetStringValue('subject', core_v2_language.GetResource('Subject_Default')); var fromEmail = core_v2_widget.GetStringValue('fromEmail', 'notset@local.com'); var toEmails = core_v2_widget.GetStringValue('toEmails', ''); var toRoleIds = core_v2_widget.GetStringValue('toRoleIds', ''); var group = core_v2_widget.GetStringValue('forumGroup', ''); //core_v2_eventLog.Write("UnansweredThread: Group: " + group, { Category: "Unanswered Threads", EventId: 18789, EventType: "Warning" }); if(group.substring(6) !== "1"){ // Get Threads while(!done){ var threads = core_v2_forumThread.List( { ForumThreadQueryType: 'Unanswered', IncludeSubGroups: true, IncludeDiscussions: false, PageIndex: pageIndex, PageSize: 100, SortBy: 'Date', SortOrder: 'Descending', GroupId: core_v2_utility.ParseInt(group.substring(6)) }); for(var t = 0; t < threads.Count; t++){ var hoursDiff = (Math.round(((new Date()) - threads[t].Date) / (60*60*1000))).toString(); if(hoursDiff > hours){ unanswered.push(threads[t].Url); } } // core_v2_eventLog.Write("UnansweredThread: Threads: " + unanswered.length, { Category: "Unanswered Threads", EventId: 18789, EventType: "Warning" }); if(threads.TotalCount <= 100 * (pageIndex + 1)){ done = true; } pageIndex++; } var hourText = ''; if(hours > 1){ hourText = core_v2_language.GetResource('Hours_Text'); } else{ hourText = core_v2_language.GetResource('Hour_Text'); } var body = '<b>Unanswered Threads after ' + hourText + '</b><br/>'; for(var u = 0; u < unanswered.length; u++){ body += '<a href="' + unanswered[u] + '">' + unanswered[u] + '</a><br/>'; } // core_v2_eventLog.Write("UnansweredThread: RoleIds: " + toRoleIds, { Category: "Unanswered Threads", EventId: 18789, EventType: "Warning" }); // Get emails to send to var splitEmails = toEmails.split(','); var splitRoles = toRoleIds.split('&'); var allEmails = []; // core_v2_eventLog.Write("UnansweredThread: SplitRoles Count: " + splitRoles.length, { Category: "Unanswered Threads", EventId: 18789, EventType: "Warning" }); for(var i = 0; i < splitRoles.length; i++){ var roleUsersDone = false; var roleUsersPageIndex = 0; var roleIdSub = splitRoles[i].substring(5); core_v2_eventLog.Write("UnansweredThread: RoleIdSub: " + roleIdSub, { Category: "Unanswered Threads", EventId: 18789, EventType: "Warning" }); var roleId = core_v2_utility.ParseInt(roleIdSub); var role = core_v2_role.Get(roleId); core_v2_eventLog.Write("UnansweredThread: RoleId: " + roleId, { Category: "Unanswered Threads", EventId: 18789, EventType: "Warning" }); core_v2_eventLog.Write("UnansweredThread: RoleName: " + role.Name, { Category: "Unanswered Threads", EventId: 18789, EventType: "Warning" }); if(role.Name === "Everyone" || role.Name === "Registered Users"){ core_v2_eventLog.Write("UnansweredThread: This role is not allowed: " + role.Name, { Category: "Unanswered Threads", EventId: 18789, EventType: "Warning" }); } else{ while(!roleUsersDone){ var roleUsers = core_v2_user.List( { PageIndex: roleUsersPageIndex, PageSize: 100, RoleId: roleId } ); if(roleUsers.Count > 0){ for(var r = 0; r < roleUsers.Count; r++){ allEmails.push(roleUsers[r].PrivateEmail); } } if(roleUsers.TotalCount <= 100 * (roleUsersPageIndex + 1)){ roleUsersDone = true; } roleUsersPageIndex++; } } } if(splitEmails.length > 0){ for(var e = 0; e < splitEmails.length; e++){ allEmails.push(splitEmails[e]); } } if(allEmails.length > 0 && unanswered.length > 0){ for(var te = 0; te < allEmails.length; te++){ core_v2_eventLog.Write("RoleUserEmailSent: " + allEmails[te], { Category: "Unanswered Threads", EventId: 18789, EventType: "Warning" }); core_v2_email.Send(subject, body, { FromEmail: fromEmail, ToEmail: allEmails[te] }); } } } else{ core_v2_eventLog.Write("UnansweredThread: Configured Group set to the site root, automation stopping.", { Category: "Unanswered Threads", EventId: 18789, EventType: "Warning" }); }]]></executionScript> <configuration><![CDATA[<propertyGroup id="options" labelResourceName="Options"> <property id="hours" labelResourceName="Hours_Label" descriptionResourceName="Hours_Desc"> <propertyRule name="minmax" min="0" /> </property> <property id="subject" labelResourceName="Subject_Label" descriptionResourceName="Subject_Desc"></property> <property id="fromEmail" labelResourceName="FromEmail_Label" descriptionResourceName="FromEmail_Desc"></property> <property id="toEmails" labelResourceName="ToEmail_Label" descriptionResourceName="ToEmail_Desc"></property> <property id="toRoleIds" labelResourceName="ToRoles_Label" descriptionResourceName="ToRoles_Desc" dataType="Custom" template="core_v2_roleLookup" enableCurrent="false" maxSelections="10" /> <property id="forumGroup" labelResourceName="ForumGroup_Label" descriptionResourceName="ForumGroup_Desc" defaultValue="Group=-1" dataType="Custom" template="core_v2_groupLookup" enableCurrent="false" /> </propertyGroup>]]></configuration> <languageResources><![CDATA[<language key="en-us"> <resource name="ForumGroup_Desc">Select a group to restrict the unanswered threads to.</resource> <resource name="ForumGroup_Label">Select a Group</resource> <resource name="FromEmail_Desc">The default is notset@local.com</resource> <resource name="FromEmail_Label">From Email Address</resource> <resource name="Hour_Text">Hour</resource> <resource name="Hours_Desc">If a thread is unanswered after the defined number of hours an email will be sent.</resource> <resource name="Hours_Label">Hours</resource> <resource name="Hours_Text">Hours</resource> <resource name="Subject_Default">Unanswered Threads</resource> <resource name="Subject_Desc">Email subject for the unanswered threads email</resource> <resource name="Subject_Label">Email Subject</resource> <resource name="ToEmail_Desc">Enter a single email or multiple emails, multiple emails should be comma delimited(test@email.com,test2@email.com)</resource> <resource name="ToEmail_Label">To Email</resource> <resource name="ToRoles_Desc">Enter a single role or multiple roles, multiple roles should be comma delimited(adminstrators,Users)</resource> <resource name="ToRoles_Label">To Roles</resource> </language>]]></languageResources> </automation> </automations> <configuredAutomations> <configuredAutomation version="11.1.8.16788" id="3df8ffefb21f4400ae5c1fd0df971658" automationId="f624be8c283d479096e806444e857bb4" name="Unanswered Threads" description="" enabled="false" lastModified="2022-01-13 20:52:57Z"> <properties> <property id="hours" dataType="String"> <value>2</value> </property> <property id="subject" dataType="String"> <value>Unanswered Questions are Waiting for Your Review</value> </property> <property id="fromEmail" dataType="String"> <value /> </property> <property id="toEmails" dataType="String"> <value /> </property> <property id="toRoleIds" dataType="Custom"> <value>Role=4&Role=9</value> </property> <property id="forumGroup" dataType="Custom"> <value>Group=2</value> </property> </properties> </configuredAutomation> </configuredAutomations> </automations>
Download for version 12:
<automations> <automations> <automation name="Unanswered Threads Notifications" version="12.0.2.17146" description="This automation sends an email with a list of Forum Thread URLs that have not been answered after x number of hours." id="f624be8c283d479096e806444e857bb4" executeAsServiceUser="true" isSingleton="false" trigger="Job" schedule="00:01 Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday" lastModified="2021-12-14 19:59:01Z"> <executionScript language="JavaScript"><![CDATA[var pageIndex = 0; var done = false; var unanswered = []; var hours = core_v2_widget.GetStringValue('hours', '18'); var subject = core_v2_widget.GetStringValue('subject', core_v2_language.GetResource('Subject_Default')); var fromEmail = core_v2_widget.GetStringValue('fromEmail', 'notset@local.com'); var toEmails = core_v2_widget.GetStringValue('toEmails', ''); var toRoleIds = core_v2_widget.GetStringValue('toRoleIds', ''); var group = core_v2_widget.GetStringValue('forumGroup', ''); core_v2_eventLog.Write("Group: " + group, { Category: "Unanswered Threads", EventId: 123675, EventType: "Warning" }); // Get Threads while(!done){ var threads = core_v2_forumThread.List( { ForumThreadQueryType: 'Unanswered', IncludeSubGroups: true, IncludeDiscussions: false, PageIndex: pageIndex, PageSize: 100, SortBy: 'Date', SortOrder: 'Descending', GroupId: core_v2_utility.ParseInt(group) }); core_v2_eventLog.Write("ThreadCount: " + threads.Count, { Category: "Unanswered Threads", EventId: 123675, EventType: "Warning" }); for(var t = 0; t < threads.Count; t++) { var hoursDiff = (Math.round(((new Date()) - threads[t].Date) / (60*60*1000))).toString(); if(hoursDiff > hours) { unanswered.push(threads[t].Url); } } if(threads.TotalCount <= 100 * (pageIndex + 1)) { done = true; } pageIndex++; } var hourText = ''; if(hours > 1) { hourText = core_v2_language.GetResource('Hours_Text'); } else { hourText = core_v2_language.GetResource('Hour_Text'); } var body = '<b>' + core_v2_language.GetResource('EmailBodyIntroText') + ' ' + hours + ' ' + hourText + ':</b>'; for(var u = 0; u < unanswered.length; u++) { body += '<p><a href="' + unanswered[u] + '">' + unanswered[u] + '</a></p>'; } // Get emails to send to var splitEmails = toEmails.split(','); var splitRoleIds = toRoleIds.split(','); var allEmails = []; for(var i = 0; i < splitRoleIds.length; i++) { core_v2_eventLog.Write("Role Users Found: ", { Category: "Unanswered Threads", EventId: 18789, EventType: "Warning" }); var roleUsersDone = false; var roleUsersPageIndex = 0; var roleId = core_v2_utility.ParseInt(splitRoleIds[i]); while(!roleUsersDone) { var roleUsers = core_v2_user.List( { PageIndex: roleUsersPageIndex, PageSize: 100, RoleId: roleId } ); if(roleUsers.Count > 0) { core_v2_eventLog.Write("Role greater than 0: ", { Category: "Unanswered Threads", EventId: 187489, EventType: "Warning" }); for(var r = 0; r < roleUsers.Count; r++) { core_v2_eventLog.Write("RoleUserEmail: " + roleUsers[r].PrivateEmail, { Category: "Unanswered Threads", EventId: 18789, EventType: "Warning" }); allEmails.push(roleUsers[r].PrivateEmail); } } if(roleUsers.TotalCount <= 100 * (roleUsersPageIndex + 1)) { roleUsersDone = true; } roleUsersPageIndex++; } } for(var e = 0; e < splitEmails.length; e++) { allEmails.push(splitEmails[e]); } if(allEmails.length > 0 && unanswered.length > 0) { for(var te = 0; te < allEmails.length; te++) { core_v2_email.Send(subject, body, { FromEmail: fromEmail, ToEmail: allEmails[te] }); } }]]></executionScript> <configuration><![CDATA[<propertyGroup id="options" labelResourceName="Options"> <property id="hours" labelResourceName="Hours_Label" descriptionResourceName="Hours_Desc"> <propertyRule name="minmax" min="0" /> </property> <property id="subject" labelResourceName="Subject_Label" descriptionResourceName="Subject_Desc"></property> <property id="fromEmail" labelResourceName="FromEmail_Label" descriptionResourceName="FromEmail_Desc"></property> <property id="toEmails" labelResourceName="ToEmail_Label" descriptionResourceName="ToEmail_Desc"></property> <property id="toRoleIds" labelResourceName="ToRoles_Label" descriptionResourceName="ToRoles_Desc" dataType="Custom" template="core_v2_roleLookup" enableCurrent="false" maxSelections="10" format="csv" /> <property id="forumGroup" labelResourceName="ForumGroup_Label" descriptionResourceName="ForumGroup_Desc" defaultValue="Group=-1" dataType="Custom" template="core_v2_groupLookup" enableCurrent="false" format="csv" /> </propertyGroup>]]></configuration> <languageResources><![CDATA[<language key="en-us"> <resource name="EmailBodyIntroText">Unanswered Threads after</resource> <resource name="ForumGroup_Desc">Select a Group to restrict the unanswered Threads to. The automation will only look at Threads in this Group.</resource> <resource name="ForumGroup_Label">Select a Group</resource> <resource name="FromEmail_Desc">The default is notset@local.com</resource> <resource name="FromEmail_Label">From Email Address</resource> <resource name="Hour_Text">Hour</resource> <resource name="Hours_Desc">If a Thread is unanswered after the defined number of hours an email will be sent.</resource> <resource name="Hours_Label">Hours</resource> <resource name="Hours_Text">Hours</resource> <resource name="Subject_Default">Unanswered Threads</resource> <resource name="Subject_Desc">Email subject for the unanswered Threads email</resource> <resource name="Subject_Label">Email Subject</resource> <resource name="ToEmail_Desc">Enter a single email or multiple emails, multiple emails should be comma delimited (test@email.com,test2@email.com).</resource> <resource name="ToEmail_Label">To Email</resource> <resource name="ToRoles_Desc">Enter a single role or multiple roles, multiple roles should be comma delimited (adminstrators,Users).</resource> <resource name="ToRoles_Label">To Roles</resource> </language>]]></languageResources> </automation> </automations> <configuredAutomations> <configuredAutomation version="12.0.2.17146" id="a55006fd54d94a86807fceb76e87e2db" automationId="f624be8c283d479096e806444e857bb4" name="Unanswered Threads" description="" enabled="false" lastModified="2021-12-14 19:58:25Z"> <properties> <property id="hours" dataType="String"> <value>48</value> </property> <property id="subject" dataType="String"> <value>There are Unanswered Forum Threads in your Community</value> </property> <property id="fromEmail" dataType="String"> <value>notset@community.com</value> </property> <property id="toEmails" dataType="String"> <value /> </property> <property id="toRoleIds" dataType="Custom"> <value /> </property> <property id="forumGroup" dataType="Custom"> <value /> </property> </properties> </configuredAutomation> </configuredAutomations> </automations>
Installation Instructions
- To import this automation please follow the documentation listed here: https://community.telligent.com/community/11/w/user-documentation/62977/how-do-i-configure-automations-for-my-community
- You will then click on "Automations" above the Automation Studio tab and click "Add"
- For the "Type of Automation" drop down, select "Unanswered Threads Notification Email"
- Configure the automation as shown below, enable it, and click save!
Configuration Options
- Schedule
- How often the automation should run. The default is set to once per day, Monday through Friday, at 8:00am.
- Hours
- The number of hours a Forum Thread has been unanswered before it is included in the email report. The default is 24 hours.
- Email Subject
- The subject of the email.
- From Email Address
- The email address that the email notification will come from.
- To Email
- Either a single email address or comma separated list of email addresses that the email will be sent to.
- To Roles
- You can scope this automation to send an email notification to all users in a specific role.
- Select a Group
- You can scope the automation to only look for unanswered Threads in a specific Group.
Automation Configuration
Automation Studio Configuration