Since they are very important to us, we receive a SMS with information about the ticket, whenever there is a new one.
Of course when we wanted to use OTRS 3.0.4 for this as well, we need to extend it to also cover SMS Notifications.
I'm been searching around, and the typical suggestions is the use a SMTP based SMS Gateway, supplied by your operator.
First of all not all operators have one, in fact in Denmark, only one provider stil has one.
Second, we still need to receive mail notifications, and the SMS Notifications shouldn't be HTML based.
Since we are a SMS Gateway provider, we wanted to use our own Gateway, which is based on HTTP (We have SMTP aswell), but many providers offer HTTP Support.
So here's the deal.
We wanted to use as many features as possible of those which allready is in OTRS, like "Receive mail on new ticket" etc. we wanted those to be general for both SMS and Mail.
Further more, we wanted to use the email templates for SMS Aswell.
We started by implementing a Mobile number on the agent.
We edited the template for adding and editing agents, here's a diff:
Code: Select all
--- /opt/otrs-3.0.4/Kernel/Output/HTML/Standard/AdminUser.dtl 2010-11-08 23:12:07.000000000 +0100
+++ /opt/otrs/Kernel/Output/HTML/Standard/AdminUser.dtl 2010-12-18 10:16:48.000000000 +0100
@@ -193,6 +193,11 @@
<input type="password" name="UserPw" id="UserPw" value="" class="W50pc" maxlength="50"/>
</div>
<div class="Clear"></div>
+ <label for="UserMobile">$Text{"Mobile"}:</label>
+ <div class="Field">
+ <input type="text" name="UserMobile" id="UserMobile" value="$QData{"UserMobile"}" class="W50pc" maxlength="50"/>
+ </div>
+ <div class="Clear"></div>
<label class="Mandatory" for="UserEmail"><span class="Marker">*</span> $Text{"Email"}:</label>
<div class="Field">
Code: Select all
--- /opt/otrs-3.0.4/Kernel/System/User.pm 2010-11-30 14:11:11.000000000 +0100
+++ /opt/otrs/Kernel/System/User.pm 2010-12-18 10:38:07.000000000 +0100
@@ -400,6 +400,9 @@
# set email address
$Self->SetPreferences( UserID => $UserID, Key => 'UserEmail', Value => $Param{UserEmail} );
+ # set mobile
+ $Self->SetPreferences( UserID => $UserID, Key => 'UserMobile', Value => $Param{UserMobile} );
+
# delete cache
my @CacheKeys = (
'GetUserData::User::' . $Param{UserLogin} . '::0::0',
@@ -495,6 +498,12 @@
Key => 'UserEmail',
Value => $Param{UserEmail}
);
+ # set mobile
+ $Self->SetPreferences(
+ UserID => $Param{UserID},
+ Key => 'UserMobile',
+ Value => $Param{UserMobile}
+ );
# delete cache
$Self->{CacheInternalObject}->CleanUp();
Code: Select all
--- /opt/otrs-3.0.4/Kernel/Modules/AdminUser.pm 2010-11-19 23:28:58.000000000 +0100
+++ /opt/otrs/Kernel/Modules/AdminUser.pm 2010-12-18 10:41:16.000000000 +0100
@@ -149,7 +149,7 @@
my $Note = '';
my ( %GetParam, %Errors );
for my $Parameter (
- qw(UserID UserTitle UserLogin UserFirstname UserLastname UserEmail UserPw ValidID Search)
+ qw(UserID UserTitle UserLogin UserFirstname UserLastname UserMobile UserEmail UserPw ValidID Search)
)
{
$GetParam{$Parameter} = $Self->{ParamObject}->GetParam( Param => $Parameter ) || '';
@@ -293,7 +293,7 @@
my $Note = '';
my ( %GetParam, %Errors );
for my $Parameter (
- qw(UserTitle UserLogin UserFirstname UserLastname UserEmail UserPw ValidID Search)
+ qw(UserTitle UserLogin UserFirstname UserLastname UserEmail UserMobile UserPw ValidID Search)
)
{
$GetParam{$Parameter} = $Self->{ParamObject}->GetParam( Param => $Parameter ) || '';
As the last thing, we need to implement it in the way notifications are sent, keep in mind we want it to work the same way as the email does, so the easiest thing, implement it the same place as an email is sent, so all the check are simular.
We use our own HTTP Bases SMS Gateway, from CoolSMS.com
As you might notice, we just strip the HTML from the email, and also replace html breaks with line breaks.
Code: Select all
--- /opt/otrs-3.0.4/Kernel/System/Ticket/Article.pm 2010-12-10 14:03:31.000000000 +0100
+++ /opt/otrs/Kernel/System/Ticket/Article.pm 2010-12-19 08:33:03.000000000 +0100
@@ -19,6 +19,11 @@
use Kernel::System::TemplateGenerator;
use Kernel::System::Notification;
use Kernel::System::EmailParser;
+# Used for the SMS Gateway implementation
+use LWP::UserAgent;
+use URI::Escape;
+use Encode;
+
use vars qw($VERSION);
$VERSION = qw($Revision: 1.266 $) [1];
@@ -2248,6 +2253,33 @@
Priority => 'notice',
Message => "Sent agent '$Param{Type}' notification to '$User{UserEmail}'.",
);
+ if($User{UserMobile}){
+ # Url encode our parameters
+ my $sender = uri_escape("OTRS Ticket");
+ my $username = uri_escape("coolsms_username");
+ my $password = uri_escape("coolsms_password");
+ my $message = $Notification{Body};
+ # Replace HTML <br/>s with line break \n
+ $message =~ s/<br\s+\/+>/\n/g;
+ # Strip all other HTML tags
+ $message =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs;
+ # Encode the message in latin1, to ensure it fits with the GSM characters
+ $message = encode("iso-8859-1", $message);
+ # Urlencode the message
+ $message = uri_escape($message);
+ # Generate the URL; and make the HTTP GET
+ my $url = "http://sms.coolsmsc.dk/sendsms.php?from=$sender&username=$username&password=$password&message=$message&to=$User{UserMobile}";
+ my $ua = new LWP::UserAgent;
+ $ua->agent("OTRS");
+ my $req = new HTTP::Request GET => $url;
+ my $res = $ua->request($req);
+
+ # Log the response, as a notice, for debug purposes
+ $Self->{LogObject}->Log(
+ Priority => 'notice',
+ Message => "Sent agent '$Param{Type}' notification to '$User{UserMobile}', CoolSMS Response: '$res->content'.",
+ );
+ }
# event
$Self->EventHandler(
If anybody is interested in this, we'll be happy to sponsor a SMS Gateway, to do the tests and implementation, in that case please contact me at mnv <at> coolsms.com
I hope that somebody will find this usefull