restotrs

OTRS/Znuny 7 notification after creating ticket via REST-API


I'm using the OTRS REST API to create tickets in OTRS/Znuny 7. The ticket creation process is successful, but the subscribers of the respective queue do not receive any notification about the new ticket.

Interestingly, when I create a ticket via email, the subscribers do receive a notification. I have also made sure that the "NoAgentNotify" field is set to 0.

My question is: Are there any other fields or settings that need to be configured in order to trigger a notification for the queue subscribers when a ticket is created via the REST API?

Request body

{
    "Ticket":
    {
        "Lorem ipsum",
        "QueueID": 35,
        "StateID": "new",
        "Lock": "unlock",
        "Priority": "3 normal"
    },
    "Article":
    {
        "CommunicationChannel": "Email",
        "From": "foo@bar.baz",
        "Subject": "Lorem ipsum",
        "Body": "Lorem ipsum dolor sit amet",
        "ContentType": "text/plain; charset=utf-8",
        "NoAgentNotify": 0
    }
}

Solution

  • To trigger the NewTicket-Notification you must add a specific HistoryType to the article.

    {
        "UserLogin":"root@localhost",
        "Password":"root",
        "Ticket":{
           "Queue":"Raw",
           "Title":"Test Ticket",
           "State":"new",
           "Priority":"3 normal",
           "CustomerUser":"customer-1"
        },
        "Article":{
            "CommunicationChannel": "Email",
            "From": "Znuny System <znuny@localhost>",
            "Subject": "Lorem ipsum",
            "Body": "Lorem ipsum dolor sit amet",
            "HistoryType": "EmailAgent",
            "ContentType": "text/plain; charset=utf-8"
        },
        "Attachment" :     
    }
    

    The HistoryType musst match the RegEx in this snippet that controls this specific notification (EmailAgent, EmailCustomer, PhoneCallCustomer, WebRequestCustomer, SystemRequest).

    if (
            $FirstArticle &&
            $Param{HistoryType}
            =~ /^(EmailAgent|EmailCustomer|PhoneCallCustomer|WebRequestCustomer|SystemRequest)$/i
        )
    {
    

    You must also add "ArticleSend": 1, to send this article as an email if that is what you want to do.