Compare commits

...

7 Commits

Author SHA1 Message Date
Peter Edmond
677ce469c7 Commented out unnecessary diagnostics for emails being sent. 2025-02-25 12:19:24 +00:00
Peter Edmond
2905301976 Added updated versions of scrips for DM RT process. 2025-02-12 22:42:30 +00:00
Peter Edmond
9522d0fb63 Updated client to Inquirer as the person isn't a client until they have accepted a contract 2025-01-16 21:32:04 +00:00
Peter Edmond
b02d6653cd Updated text, and removal of unwanted hidden unicode chars 2025-01-07 16:57:32 +00:00
Peter Edmond
976099c3d3 Added From field to the email headers 2024-12-16 16:25:10 +00:00
Peter Edmond
e4a535f333 Updated facilitators email process and captured race condition. 2024-12-15 23:45:28 +00:00
Peter Edmond
33b2bdcd57 Added Scrip2 to send redacted facilitator email 2024-12-15 21:58:31 +00:00
11 changed files with 526 additions and 16 deletions

View File

@@ -1,13 +1,16 @@
Subject: AutoReply: {$Ticket->Subject} From: Davis Method <test-queue@davismethod.com>
Subject: {$Ticket->Subject}
Content-Type: text/html Content-Type: text/html
<p>Hello from Davis,</p>
<p>Thankyou for your interest in the Davis Method. We have received your message and will aim to get back to you within 2 working days. There is no need to reply to this message right now. Your interest has been <p>Your form was submitted with ID #{$Ticket->id}.</p>
assigned an ID of <b>{$Ticket->SubjectTag}</b>.</p>
<p>Should you wish to contact us relating to this then please include the string <b>{$Ticket->SubjectTag}</b> <p>Thank you so much for reaching out to a Davis Facilitator and expressing interest in a Davis program.</p>
in the subject line of all future correspondence about this case.</p>
<p>Best regards</p> <p>Your inquiry is important to us, and a member of our team will get back to you within 3 business days. In the meantime, feel free to explore our website for more information. Of particular interest may be our section on <a href='https://davismethod.com/search-solutions/'>Davis Solutions</a>.</p>
<p>....</p> <p>We look forward to connecting with you soon.</p>
<p>Warmest regards,<br>
Davis Team</p>

View File

@@ -1,14 +1,12 @@
Subject: AutoReply: {$Ticket->Subject} From: Davis Method <test-queue@davismethod.com>
Subject: Davis Method Facilitator Enquiry
Content-Type: text/html Content-Type: text/html
<p>A person has expressed interest in the Davis Method.<p> <p>Congratulations! You have received a referral from the Davis Facilitator Directory. You can view it by visiting <a href="https://support.davismethod.com/form?id={$Ticket->id}&email={$Ticket->FirstCustomFieldValue('Facilitator Email')}&uuid={$Ticket->FirstCustomFieldValue('uuid')}">this link</a>.</p>
<p>They have provided the following information:</p> <p>If you have any issues clicking on the link above, please copy and paste the following link into your browser https://support.davismethod.com/form?id={$Ticket->id}&email={$Ticket->FirstCustomFieldValue('Facilitator Email')}&uuid={$Ticket->FirstCustomFieldValue('uuid')}</p>
<pre>
{$Info}
</pre>
<p>If you are interested in this client, then please confirm your interest in this client in the next 48 hours by going to https://support.davismethod.com/form?{$uniqueID} <p> <p>Please accept or reject the lead in the next 48 hours. If we do not hear from you, the referral will be reassigned.</p>
<p>The Davis Team</p> <p>The Davis Team</p>

17
FacilitatorFullEmail.txt Normal file
View File

@@ -0,0 +1,17 @@
From: Davis Method <test-queue@davismethod.com>
Subject: Davis Method Inquiry
Content-Type: text/html
<p>Below are the full details of the lead. Unless you have other arrangements with your Hub, please follow up with this contact below from <b>your davismethod.com email address</b> as soon as possible (within 24 hours is ideal).</p>
<p>Form details:</p>
{$Ticket->FirstCustomFieldValue('Redacted Form Details')}
{$Ticket->FirstCustomFieldValue('Form Details')}
<p>We hope that this will turn into a successful program!</p>
<br>
<p>Warm Regards,</p>
<p>The Davis Team</p>

View File

@@ -35,7 +35,7 @@ my ( @To, @PseudoTo, @Cc, @Bcc );
my $arg ='Owner,Requestor,AdminCc,Cc'; my $arg ='Owner,Requestor,AdminCc,Cc';
##Requestor ##Requestor
#push @To, $ticket->Requestors->MemberEmailAddresses; #push @To, $ticket->Requestors->MemberEmailAddresses;
push @To, $ticket->FirstCustomFieldValue('Client Email'); push @To, $ticket->FirstCustomFieldValue('Inquirer Email');
my $creator = "Davis Admin"; my $creator = "Davis Admin";
@{ $self->{'To'} } = @To; @{ $self->{'To'} } = @To;
@@ -54,7 +54,7 @@ my $queue = $ticket->FirstCustomFieldValue('Hub Queue');
#$ticket->Comment(Content => 'Script #21 - sending email to requestor'); #$ticket->Comment(Content => 'Script #21 - sending email to requestor');
#$ticket->Comment(Content => 'Status is: '.$self->TicketObj->Status()); #$ticket->Comment(Content => 'Status is: '.$self->TicketObj->Status());
$ticket->Comment(Content => 'AUTO: Email sent to requestor is: '.$ticket->FirstCustomFieldValue('Client Email')); $ticket->Comment(Content => 'AUTO: Email sent to requestor is: '.$ticket->FirstCustomFieldValue('Inquirer Email'));
# $ticket->Comment(Content => 'To is: '.@{ $self->{'To'} }); # $ticket->Comment(Content => 'To is: '.@{ $self->{'To'} });
#Now change Queue #Now change Queue

86
Scrip22.txt Normal file
View File

@@ -0,0 +1,86 @@
# On create:
# - Sent email to requestor
# - Check queue, and transfer to new queue if required
# Custom condition:
my $txn = $self->TransactionObj;
my $type = $txn->Type;
my $ticket = $self->TicketObj;
if ($ticket->Status() eq "Redacted Facilitator Email Sent") {
return 0;
}
return 0 unless $type eq "Status" || ( $type eq 'Set' && $txn->Field eq 'Status');
return 0 unless $txn->OldValue eq "new";
return 0 unless $txn->NewValue eq "Hub Not Assigned";
# To test by triggering change of status (Condition ^ above!)
#Only act in test-queue (safety for testing)
return 0 unless $ticket->QueueObj->Name eq "test-queue";
#Only act on creation
#return 0 unless $txn->Type eq "Create";
# ONLY run script if current status is "Hub Not Assigned"
if ($ticket->Status() eq "Hub Not Assigned") {
return 1;
}
return 0;
# Custom action preparation code:
require RT::Action::SendEmail;
use strict;
use vars qw/@ISA/;
@ISA = qw(RT::Action::SendEmail);
#STOP RACE CONDITION!
if ($self->TicketObj->Status() ne "Hub Not Assigned") {
if ($self->TicketObj->Status() ne "Re-send Facilitator Email") {
return 0;
}
}
$self->SetRecipients();
$self->SUPER::Prepare();
$self->SUPER::Commit();
sub SetRecipients {
my $self = shift;
my $ticket = $self->TicketObj;
my ( @To, @PseudoTo, @Cc, @Bcc );
my $arg ='Owner,Requestor,AdminCc,Cc';
##Requestor
#push @To, $ticket->Requestors->MemberEmailAddresses;
push @To, $ticket->FirstCustomFieldValue('Facilitator Email');
my $creator = "Davis Admin";
@{ $self->{'To'} } = @To;
}
1;
# Custom action commit code:
#Move to Redacted Facilitator email sent.
my $ticket = $self->TicketObj;
my $facilitator = $ticket->FirstCustomFieldValue('Facilitator Email');
if ($ticket->FirstCustomFieldValue('Facilitator Email') eq '') {
return 0;
}
#if ($ticket->Status() ne "new") {
# return 1;
#}
#$ticket->Comment(Content => 'Script #22 - sending email to facilitator');
#$ticket->Comment(Content => 'Status is: '.$self->TicketObj->Status());
$ticket->Comment(Content => 'AUTO: Email sent. Facilitator is: '.$ticket->FirstCustomFieldValue('Facilitator Email'));
$ticket->Comment(Content => 'AUTO: Changing status to "Redacted Facilitator Email Sent"');
my ($status, $msg) = $ticket->SetStatus('Redacted Facilitator Email Sent');
return 1;

74
Scrip24.txt Normal file
View File

@@ -0,0 +1,74 @@
# On client accepted:
# - Sent full detail email to facilitator
# Custom condition:
my $txn = $self->TransactionObj;
my $type = $txn->Type;
my $ticket = $self->TicketObj;
return 0 unless $type eq "Status" || ( $type eq 'Set' && $txn->Field eq 'Status');
#return 0 unless $txn->OldValue eq "new";
#return 0 unless $txn->NewValue eq "Hub Not Assigned";
# To test by triggering change of status (Condition ^ above!)
#Only act in test-queue (safety for testing)
return 0 unless $ticket->QueueObj->Name eq "test-queue";
# ONLY run script if current status is "Facilitator Accepted"
if ($ticket->Status() eq "Facilitator Accepted") {
return 1;
}
return 0;
# Custom action preparation code:
require RT::Action::SendEmail;
use strict;
use vars qw/@ISA/;
@ISA = qw(RT::Action::SendEmail);
#STOP RACE CONDITION!
if ($self->TicketObj->Status() ne "Facilitator Accepted") {
return 0;
}
$self->SetRecipients();
$self->SUPER::Prepare();
$self->SUPER::Commit();
sub SetRecipients {
my $self = shift;
my $ticket = $self->TicketObj;
my ( @To, @PseudoTo, @Cc, @Bcc );
my $arg ='Owner,Requestor,AdminCc,Cc';
##Requestor
#push @To, $ticket->Requestors->MemberEmailAddresses;
push @To, $ticket->FirstCustomFieldValue('Facilitator Email');
my $creator = "Davis Admin";
@{ $self->{'To'} } = @To;
}
1;
# Custom action commit code:
#Move to Full Facilitator Email Sent and detailed email sent.
my $ticket = $self->TicketObj;
my $facilitator = $ticket->FirstCustomFieldValue('Facilitator Email');
if ($ticket->FirstCustomFieldValue('Facilitator Email') eq '') {
return 0;
}
$ticket->Comment(Content => 'AUTO: Email with all details sent. Facilitator is: '.$ticket->FirstCustomFieldValue('Facilitator Email'));
$ticket->Comment(Content => 'AUTO: Changing status to "Full Facilitator Email Sent"');
my ($status, $msg) = $ticket->SetStatus('Full Facilitator Email Sent');
return 1;

74
Scrip25.txt Normal file
View File

@@ -0,0 +1,74 @@
#Check and change queue as required
# On create
# User Defined
my $txn = $self->TransactionObj;
my $type = $txn->Type;
my $ticket = $self->TicketObj;
if ($ticket->Status() ne "New") {
return 0;
}
return 1;
# Custom action
return 1;
# Commit:
my $ticket = $self->TicketObj;
my $queue = $ticket->FirstCustomFieldValue('Hub Queue');
#if ($ticket->Status() ne "new") {
# return 1;
#}
#This potentially means that the email is spam if it's missing, so we could potentially move it somewhere else?
if ($ticket->FirstCustomFieldValue('Inquirer Email') eq '') {
return 0;
}
$ticket->Comment(Content => 'AUTO: Scrip #25New ticket. Current queue is: '.$ticket->QueueObj->Name.'. Required queue is: '.$queue);
#Now change Queue
#Get current queue?:
if (($queue eq $ticket->QueueObj->Name) || ($queue eq "")) {
$ticket->Comment(Content => 'AUTO: Scrip #25 Leaving in current queue');
my ($status, $msg) =$ticket->SetStatus('Inquirer Autoresponse Sent');
} else {
my ($status, $msg) = $ticket->SetQueue( $queue);
if ($status == 0) {
$ticket->Comment(Content => 'AUTO: Scrip #25 Error changing queue to: '.$queue.' - '.$msg);
} else {
$ticket->Comment(Content => 'AUTO: Scrip #25 Changing queue to: '.$queue);
my ($status, $msg) =$ticket->SetStatus('Inquirer Autoresponse Sent');
}
}
# Check and assign Queue Managers =======
my $groupname;
if (( $ticket->QueueObj->Name) eq "Contact Facilitator") {
$groupname="Inquiries - Contact Facilitator";
} elsif (( $ticket->QueueObj->Name) eq "Contact North America") {
$groupname="Inquiries - Hub North America";
} else {
$groupname="Inquiries - Test";
}
my $groupObj = RT::Group->new($RT::SystemUser);
$groupObj->LoadUserDefinedGroup($groupname);
return undef unless $groupObj;
my $role = RT::CustomRole->new( $self->CurrentUser );
$role->Load( "Queue Managers" );
my ($success, $msg) = $self->TicketObj->AddWatcher( Type => $role->GroupType, PrincipalId => $groupObj->Id );
return 1;

68
Scrip26.txt Normal file
View File

@@ -0,0 +1,68 @@
#Enhanced send equirer email:
#Custom condition:
# This script first checks if the inquirer has already been messaged
# Then assembles email
# Sends email
# Sets flag that inquirer has already been messaged.
my $txn = $self->TransactionObj;
my $type = $txn->Type;
return 0 unless $self->TicketObj->FirstCustomFieldValue('Inquirer Auto-Response Sent') ne 'Yes';
return 0 unless $type eq "Status" || ( $type eq 'Set' && $txn->Field eq 'Status');
return 0 unless $self->TicketObj->Status eq "Inquirer Autoresponse Sent";
return 1;
# Custom Action Preparation Code:
require RT::Action::SendEmail;
use strict;
use vars qw/@ISA/;
@ISA = qw(RT::Action::SendEmail);
$self->SetRecipients();
$self->SUPER::Prepare();
$self->SUPER::Commit();
sub SetRecipients {
my $self = shift;
my $ticket = $self->TicketObj;
my ( @To, @PseudoTo, @Cc, @Bcc );
my $arg ='Owner,Requestor,AdminCc,Cc';
##Requestor
#push @To, $ticket->Requestors->MemberEmailAddresses;
push @To, $ticket->FirstCustomFieldValue('Inquirer Email');
my $creator = "Davis Admin";
@{ $self->{'To'} } = @To;
}
my $value_set = $self->TicketObj->AddCustomFieldValue(Field => 'Inquirer Auto-Response Sent', Value => 'Yes');
# $self->TicketObj->Comment(Content => 'AUTO Scrip #26 changing sent status:- '.$value_set);
unless ($value_set) {
$RT::Logger->error("Failed to set custom field value for 'Inquirer Auto-Response Sent'");
return 0;
}
$RT::Logger->error($self->TransactionObj->Type);
$RT::Logger->error($self->TransactionObj->NewValue);
1;
# Custom Commit Code:
# Now move ticket to next step as required.
my $ticket = $self->TicketObj;
$ticket->Comment(Content => 'AUTO Scrip #26 - sent email to inquirer');
my ($status, $msg) =$ticket->SetStatus('Redacted Facilitator Email Sent');
1;

72
Scrip27.txt Normal file
View File

@@ -0,0 +1,72 @@
# Enhanced send facilitator initial email
# Custom conditions
# Custom Email
# Template - Send Facilitator Email
# Conditions:
# This script first checks for correct status
# Then assembles email
# Sends email
my $txn = $self->TransactionObj;
my $type = $txn->Type;
return 0 unless $type eq "Status" || ( $type eq 'Set' && $txn->Field eq 'Status');
return 0 unless $self->TicketObj->Status eq "Redacted Facilitator Email Sent";
return 1;
# Custom preparation:
require RT::Action::SendEmail;
use strict;
use vars qw/@ISA/;
@ISA = qw(RT::Action::SendEmail);
#STOP RACE CONDITION!
if ($self->TicketObj->Status() ne "Redacted Facilitator Email Sent") {
if ($self->TicketObj->Status() ne "Re-send Facilitator Email") {
return 0;
}
}
$self->SetRecipients();
$self->SUPER::Prepare();
$self->SUPER::Commit();
sub SetRecipients {
my $self = shift;
my $ticket = $self->TicketObj;
my ( @To, @PseudoTo, @Cc, @Bcc );
my $arg ='Owner,Requestor,AdminCc,Cc';
##Requestor
#push @To, $ticket->Requestors->MemberEmailAddresses;
push @To, $ticket->FirstCustomFieldValue('Facilitator Email');
my $creator = "Davis Admin";
@{ $self->{'To'} } = @To;
}
1;
# Custom Commit
#Move to Redacted Facilitator email sent.
my $ticket = $self->TicketObj;
my $facilitator = $ticket->FirstCustomFieldValue('Facilitator Email');
if ($ticket->FirstCustomFieldValue('Facilitator Email') eq '') {
return 0;
}
$ticket->Comment(Content => 'AUTO Scrip #27: Email sent. Facilitator is: '.$ticket->FirstCustomFieldValue('Facilitator Email'));
#$ticket->Comment(Content => 'AUTO Scrip #27: Redacted Facilitator Email Sent');
#my ($status, $msg) = $ticket->SetStatus('Redacted Facilitator Email Sent');
return 1;

69
Scrip28.txt Normal file
View File

@@ -0,0 +1,69 @@
# Enhanced Send Facilitator Unredacted Email
#
#
# Template - Demo Send Facilitators Full Email
# Custom Conditions:
# This script first checks for correct status
# Then assembles email
# Sends email
my $txn = $self->TransactionObj;
my $type = $txn->Type;
return 0 unless $type eq "Status" || ( $type eq 'Set' && $txn->Field eq 'Status');
return 0 unless $self->TicketObj->Status eq "Facilitator Accepted";
return 1;
# Custom Preparation
require RT::Action::SendEmail;
use strict;
use vars qw/@ISA/;
@ISA = qw(RT::Action::SendEmail);
#STOP RACE CONDITION!
if ($self->TicketObj->Status() ne "Facilitator Accepted") {
return 0;
}
$self->SetRecipients();
$self->SUPER::Prepare();
$self->SUPER::Commit();
sub SetRecipients {
my $self = shift;
my $ticket = $self->TicketObj;
my ( @To, @PseudoTo, @Cc, @Bcc );
my $arg ='Owner,Requestor,AdminCc,Cc';
##Requestor
#push @To, $ticket->Requestors->MemberEmailAddresses;
push @To, $ticket->FirstCustomFieldValue('Facilitator Email');
my $creator = "Davis Admin";
@{ $self->{'To'} } = @To;
}
1;
# Custom commit
# Move to Full Facilitator Email Sent and detailed email sent.
my $ticket = $self->TicketObj;
my $facilitator = $ticket->FirstCustomFieldValue('Facilitator Email');
if ($ticket->FirstCustomFieldValue('Facilitator Email') eq '') {
return 0;
}
$ticket->Comment(Content => 'AUTO Scrip #28: Email with all details sent. Facilitator is: '.$ticket->FirstCustomFieldValue('Facilitator Email'));
$ticket->Comment(Content => 'AUTO Scrip #28: Changing status to "Full Facilitator Email Sent"');
my ($status, $msg) = $ticket->SetStatus('Full Facilitator Email Sent');
return 1;

49
Scrip29.txt Normal file
View File

@@ -0,0 +1,49 @@
# On receiving email (On correspondence):
# - Set Action Needed custom flag
# Custom condition:
return 0 unless $self->TransactionObj->Type eq "Correspond";
return 0 unless $self->TicketObj->FirstCustomFieldValue('Action Needed') ne "Yes";
#$self->TicketObj->Comment(Content => 'AUTO Scrip #29 Setting Action Needed - Condition');
#return 0 unless $self->TicketObj->Transactions->Last eq 'Email';
#return 0 unless $self->TicketObj->Transactions->Last->CreatorObj->Privileged;
1;
# Custom action preparation code:
1;
# Custom action commit code:
#Set custom flag on receiving external email
my $transaction = $self->TransactionObj;
my $creator_id = $transaction->Creator;
# Get the Ticket object
my $ticket = $self->TicketObj;
# Retrieve the most recent transaction (action)
my $last_transaction = $ticket->Transactions->Last;
# Access the description of the last transaction
my $last_transaction_description = $last_transaction->Description;
if ($last_transaction_description eq 'Outgoing email recorded by RT_System') {
# $self->TicketObj->Comment(Content => 'AUTO Scrip #29 Setting Action Needed - Commit'.$last_transaction_description);
} else {
$self->TicketObj->AddCustomFieldValue(Field => 'Action Needed', Value => 'Yes');
}
return 1;