New ticket create doesnot send autoreply to customers.

Moderator: crythias

Post Reply
szn0007
Znuny newbie
Posts: 28
Joined: 10 Jul 2016, 08:59
Znuny Version: 3.1.12
Real Name: Sujan Shrestha
Company: Classictech

New ticket create doesnot send autoreply to customers.

Post by szn0007 »

I am using php soap api to create OTRS tickets . Tickets gets created but autoreply is not going to the customers. here is my code.

$url = "https://otrs.com.np/otrs/rpc.pl"; // URL for OTRS server
$username = "ctdeveloper"; // SOAP username set in sysconfig
$password = "ctdeveloper"; // SOAP password set in sysconfig

$typeID = 2; // id from ticket_type table
// $queueID = 2; // id from queue table
// $priorityID = 1; // id from ticket_priority table
$ownerID = 1; // id from users table


### Form Fields

$user = $_POST['username_id'];
$queueID = $_POST['queue'];
$issue_type = $_POST['issue_type'];
$subject = $_POST['subject'];
$title = $user.'-Issue With'.' '.$issue_type.' -'.$subject;
$description = $_POST['description'];
$category = $_POST['category'];
$priorityID = $_POST['priority'];
$to = $_POST['to'];

#### Initialize new client session ####
$client = new SoapClient(
null,
array(
'location' => $url,
'uri' => "Core",
'trace' => 1,
'login' => $username,
'password' => $password,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED
)
);

#### Create a new ticket shell. The function returns the Ticket ID ####
$TicketID = $client->__soapCall(
"Dispatch", array($username, $password,
"TicketObject", "TicketCreate",
"Title", $title,
"TypeID", $typeID,
"QueueID", $queueID,
"LockID", 1,
"PriorityID", $priorityID,
"State", "new",
"CustomerUser", $user,
"OwnerID", $ownerID,
"UserID", 1,
)
);

##### Create an article with the info. The function returns an Article ID ####
$ArticleID = $client->__soapCall("Dispatch",
array($username, $password,
"TicketObject", "ArticleCreate",
"TicketID", $TicketID,
"ArticleType", $category,
"SenderType", "customer",
"HistoryType", "WebRequestCustomer",
"HistoryComment", "created from PHP",
"From", $user,
"To", $to,
"Subject", $title,
"ContentType", "text/plain; charset=ISO-8859-1",
"Body", $description,
"UserID", 1,
"Loop", 0,
"NoAgentNotify" , 0,
"MimeType" , "text/plain",
"AutoResponseType", 'auto reply',
"OrigHeader", array(
'From' => $to,
'To' => '$from',
'Subject' => $title,
'Body' => "$description"
),
)
);


# Use the Ticket ID to retrieve the Ticket Number.
$TicketNum = $client->__soapCall("Dispatch",
array($username, $password,
"TicketObject", "TicketNumberLookup",
"TicketID", $TicketID,
));


# Make sure the ticket number is not displayed in scientific notation
$big_integer = 1202400000;
$Formatted_TicketNum = number_format($TicketNum, 0, '.', '');


# Print the info to the screen.


echo "<script>alert('You have successfully created ticket number $Formatted_TicketNum.')</script>";
Post Reply