<automations>
	<automations>
		<automation name="NoResponse Threads Notifications" version="13.0.2.33658" 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="2025-08-05 18:53:06Z">
			<executionScript language="JavaScript"><![CDATA[var pageIndex = 0;
var done = false;
var NoResponse = [];

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: "NoResponse Threads", EventId: 652384, EventType: "Warning" });

// Get Threads
while(!done){
    var threads = core_v2_forumThread.List(
        { 
            ForumThreadQueryType: 'NoResponse',
            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: "NoResponse Threads", EventId: 652384, 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)
        {
            NoResponse.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 < NoResponse.length; u++)
{
    body += '<p><a href="' + NoResponse[u] + '">' + NoResponse[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: "NoResponse 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: "NoResponse Threads", EventId: 187489, EventType: "Warning" });
            for(var r = 0; r < roleUsers.Count; r++)
            {
                core_v2_eventLog.Write("RoleUserEmail: " + roleUsers[r].PrivateEmail, { Category: "NoResponse 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 && NoResponse.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">Threads with no response after</resource>
  <resource name="ForumGroup_Desc">Select a Group to restrict the threads with no response 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 has no response 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">Thread without a response</resource>
  <resource name="Subject_Desc">Email subject for the Threads with no response 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="13.0.2.33658" id="d64b3757702540efa4584994ffb99890" automationId="f624be8c283d479096e806444e857bb4" name="Threads with No Response" description="&lt;p&gt;This automation will deliver an email with a list of threads without a response to an email or users in a role specified. The automation can be configured to specific groups or choose the site root group for all groups on your community.&lt;/p&gt;" enabled="false" lastModified="2025-08-05 18:53:06Z">
			<properties>
				<property id="hours" dataType="String">
					<value>10</value>
				</property>
				<property id="subject" dataType="String">
					<value>There are Threads with no response in the Community!</value>
				</property>
				<property id="fromEmail" dataType="String">
					<value>notset@local.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>