I want to be able to automagically generate tickets from my app, as if they were generated from the "new ticket" button on the osTicket page by a support person.... rather than have support monitor different snmp events and email patterns.  Catching the input triggers is simple... but I'm hung up on being able to create the tickets as if a support person was manually creating them.All my attempts so far have resulted in the tickets looking like the user created them themselves... when they were in fact created through the automation.I've looked at sending an email (to the user who needs to be notified, from the support desk), and the exposed options in the API ,using the following template:$data = array(    'name'      =>      'from me',    'email'     =>      'me@me.com',    'subject'   =>      'Test API message',    'message'   =>      'This is a test of the osTicket API',    'ip'        =>      'api allowed ip :) ',    'attachments' => array(),);With no success (yes, the ticket is created.. but not as if the support person manually created it).I've also done a little digging through the code and I cant see any obvious way of doing this... All my attempts to send an email (as per above) ends up with the user getting a standard "support request opened" template message... not the details of the support ticket that were sent to osTicket.  Same for a JSON inject through the API.I'd really like the message that was sent to osTicket to be forwarded to the user and identify that it was created by support, not the user.I would think this would be a 'simple' activity - open a ticket on behalf of a user (the API providing the accreditation of the ability to create tickets)... but I cant figure out how.I'd hate to have to write directly to the database... and I didnt see a mod available... but this is available through the screen - so it's possible - its just a matter of figuring out the hooks to inject it through the API...Anyone have any ideas?

The outgoing a ticket was opened template is the template... there is no way to add a template for your use condition with out altering the source.

I played with this a little last night - got the API to accept new values,  and fed them through to the point that it was performing the Ticket: (using source as "Staff" rather than API) .... also ended up supplying the additional value for the help topid ID that it seems to want when performing the manual add that wasnt required with the "API" user.... so its definitely triggering a different condition set...But the ticket is still being created as if a user is submitting through email.   The source shows different, but the entry in the ticket history shows it was created by the user, and the email response is that there was a ticket opened... not the content that I sent.  The only thing I can think of is that there are 2 paths through the system... the API and users follow one, whereas the logged in support users follow another (before hitting common low level functionality).Is the "normal" workflow not followed when a support person submits a ticket?

Ok - there is a second path though the system... Ticket: is used for staff....

here's my plan of attack - let me know if you think I'm missing something.

Add new “asStaff” option to API

In api.ticket.php – check for new “asStaff” -> true

  if found  use Ticket::open($vars, &$errors)   

(not create... allow non "asStaff" to follow existing path) 

   (likely need to add additional values to the API to support the 'open' call)

Everything should be able to be contained inside of api.ticket.php from the looks of it...

Logically sounds good to me.  But I should mention that the API is on the table for a revamp soon... (I'm not sure how soon, but pretty sure this quarter or next)

I'll fork on github and let you decide what to do with it :)

pull request there for you.Sample JSON array:

$data = array(

'name' => 'slartibardfast',

'email' => 'me@myemail.com',

'subject' => 'Test API message',

'message' => 'This is a test of the osTicket extended API',

'ip' => 'a.b.c.d',

'attachments' => array() ,

'source' => 'other',

'asStaff' => 1,

'topicId' => 1

);

Source should be one of "email", "phone", "other"

asStaff can be either id# of the Staff member, or staff name (creation of new Staff allows both options already... 1 is just easier)

topicId is required by the validation, represents a topic# reference for user.

hmm... some deeper side effects. My testing has been through an interactive PHP interpreter, and I just got a slew of these emailsThe culprit seems to be that there is old code in my v1.9.2 that was upgraded from 1.8.0 ...The select that it's complaining about has no relevance to the database content of that table... id=1 refers to the 'isonline' key.. Unknown column 'ostversion' in 'field list'---- Backtrace ----#0 (root)/include/mysqli.php(169): osTicket->logDBError('DB Error #1054', '[SELECT `ostver...')#1 (root)/include/class.config.php(1208): db_query('SELECT `ostvers...')#2 (root)/include/class.ostsession.php(35): OsticketConfig->getDBVersion()#3 (root)/include/class.ostsession.php(154): osTicketSession->osTicketSession(86400)#4 (root)/include/class.osticket.php(58): osTicketSession->start(86400)#5 (root)/include/class.osticket.php(448): osTicket->osTicket()#6 (root)/include/api.tickets.php(129): osTicket->start()#7 (root)/include/api.tickets.php(106): TicketApiController->createTicket(Array)#8 : TicketApiController->create('json')#9 (root)/include/class.dispatcher.php(145): call_user_func_array(Array, Array)#10 (root)/include/class.dispatcher.php(38): UrlMatcher->dispatch('/tickets.json', NULL)#11 (root)/api/http.php(31): Dispatcher->resolve('/tickets.json')#12 {main}

You can use a ticket filter to match tickets created via the API. You can send an auto-reply using a canned response embedded in the 'new ticket auto-reply' email template. Since you can customize both, I would think that you should be able to get pretty close to what you want.Furthermore, you can define a custom internal field for new tickets to contain the 'asStaff' variable or any other switch, and use that data in the ticket filter as well.Cheers,

Write a Reply...