GenericInterface (PHP-SOAP) does not respect TO field in article data

Moderator: crythias

Locked
dsepeur
Znuny newbie
Posts: 19
Joined: 30 Sep 2019, 15:05
Znuny Version: 6 community edition
Real Name: Daniel Sepeur
Company: TREND Service GmbH

GenericInterface (PHP-SOAP) does not respect TO field in article data

Post by dsepeur »

Hello @all,

this post can be identified as double post, but i wish it can stay here to. The same question i asked in the Howto-Section as reply to an exisiting thread. But this thread is so old, that i decided to post it here to in hope, to get an answer for my question.
So please, Moderator, would you please be so kind to let my post here also active?

I am wondering about the GenericInterface (SOAP) behaviour from OTRS.
Im trying to create a ticket via PHP wich is okay so far. Ticket gets created.
The situation im standing in front of is, that i need to create an E-Mail ticket with its sender E-Mail address for a customer with its E-Mail address.
Background is: I send an email and create a ticket from it.
In the ticket details i need to see:

From: mycolleages@email-address.com
To: ourcustomers@email-address.com

I tried to solve this (corresponding to the interface description) by setting To: at the article data array.
But everytime i send the request to the GenericInterface, it gives me the Queue name back instead of the customers@email-address.com.
What i mean is that i see in the ticket details something like this:

From: mycolleages@email-address.com
To: OTRS Queue name

In the SOAP request, the To field getes delivered. In the response, i see just the OTRS queue name instead of the customers E-Mail address (customers@email-address.com).

It makes life hard if a colleague opens a ticket, click to answer and the To field for the ticket answer is empty.

Does anyone know how to solve this?

Thanks in advance for all responses

Daniel
root
Administrator
Posts: 4250
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: GenericInterface (PHP-SOAP) does not respect TO field in article data

Post by root »

Hi,

The request you send would be helpful.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
dsepeur
Znuny newbie
Posts: 19
Joined: 30 Sep 2019, 15:05
Znuny Version: 6 community edition
Real Name: Daniel Sepeur
Company: TREND Service GmbH

Re: GenericInterface (PHP-SOAP) does not respect TO field in article data

Post by dsepeur »

Hi,

this is the request/response pair:

Request

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="MyNamespace" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <SOAP-ENV:Body>
      <ns1:TicketCreate>
         <CustomerUserLogin xsi:type="xsd:string" />
         <UserLogin xsi:type="xsd:string">ticketrobot</UserLogin>
         <Password xsi:type="xsd:string">*********</Password>
         <Ticket xsi:type="ns2:Map">
            <item>
               <key xsi:type="xsd:string">TicketID</key>
               <value xsi:type="xsd:int">0</value>
            </item>
            <item>
               <key xsi:type="xsd:string">Title</key>
               <value xsi:type="xsd:string">My subject</value>
            </item>
            <item>
               <key xsi:type="xsd:string">From</key>
               <value xsi:type="xsd:string">mycolleagues@email-address.com</value>
            </item>
            <item>
               <key xsi:type="xsd:string">Queue</key>
               <value xsi:type="xsd:string">OTRS Queue Name</value>
            </item>
            <item>
               <key xsi:type="xsd:string">Lock</key>
               <value xsi:type="xsd:string">unlock</value>
            </item>
            <item>
               <key xsi:type="xsd:string">Priority</key>
               <value xsi:type="xsd:string">3 normal</value>
            </item>
            <item>
               <key xsi:type="xsd:string">State</key>
               <value xsi:type="xsd:string">new</value>
            </item>
            <item>
               <key xsi:type="xsd:string">CustomerUser</key>
               <value xsi:type="xsd:string">mycolleagues@email-address.com</value>
            </item>
            <item>
               <key xsi:type="xsd:string">OwnerID</key>
               <value xsi:type="xsd:int">1</value>
            </item>
            <item>
               <key xsi:type="xsd:string">Location</key>
               <value xsi:type="xsd:string" />
            </item>
            <item>
               <key xsi:type="xsd:string">Room number</key>
               <value xsi:type="xsd:string" />
            </item>
            <item>
               <key xsi:type="xsd:string">Contact</key>
               <value xsi:type="xsd:string" />
            </item>
         </Ticket>
         <Article xsi:type="ns2:Map">
            <item>
               <key xsi:type="xsd:string">From</key>
               <value xsi:type="xsd:string">mycolleagues@email-address.com</value>
            </item>
            <item>
               <key xsi:type="xsd:string">To</key>
               <value xsi:type="xsd:string">customers@email-address.com</value>
            </item>
            <item>
               <key xsi:type="xsd:string">Subject</key>
               <value xsi:type="xsd:string">Articles Subject</value>
            </item>
            <item>
               <key xsi:type="xsd:string">Body</key>
               <value xsi:type="xsd:string">THIS IS JUST A TEST</value>
            </item>
            <item>
               <key xsi:type="xsd:string">MimeType</key>
               <value xsi:type="xsd:string">text/html</value>
            </item>
            <item>
               <key xsi:type="xsd:string">Charset</key>
               <value xsi:type="xsd:string">utf8</value>
            </item>
            <item>
               <key xsi:type="xsd:string">CommunicationChannel</key>
               <value xsi:type="xsd:string">Email</value>
            </item>
            <item>
               <key xsi:type="xsd:string">HistoryType</key>
               <value xsi:type="xsd:string">NewTicket</value>
            </item>
            <item>
               <key xsi:type="xsd:string">HistoryComment</key>
               <value xsi:type="xsd:string">%%GenericInterface Create</value>
            </item>
         </Article>
      </ns1:TicketCreate>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Response

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <soap:Body>
      <TicketCreateResponse xmlns="MyNamespace">
         <ArticleID>1431</ArticleID>
         <Ticket>
            <Age>0</Age>
            <ArchiveFlag>n</ArchiveFlag>
            <Article>
               <ArticleID>1431</ArticleID>
               <ArticleNumber>1</ArticleNumber>
               <Bcc />
               <Body>THIS IS JUST A TEST</Body>
               <Cc />
               <ChangeBy>5</ChangeBy>
               <ChangeTime>2019-09-30 12:17:44</ChangeTime>
               <Charset>utf8</Charset>
               <CommunicationChannelID>1</CommunicationChannelID>
               <ContentCharset>utf8</ContentCharset>
               <ContentType>text/plain; charset=utf8</ContentType>
               <CreateBy>5</CreateBy>
               <CreateTime>2019-09-30 12:17:44</CreateTime>
               <From>mycolleagues@email-address.com</From>
               <InReplyTo />
               <IncomingTime>1569845864</IncomingTime>
               <IsVisibleForCustomer>1</IsVisibleForCustomer>
               <MessageID />
               <MimeType>text/plain</MimeType>
               <References />
               <ReplyTo />
               <SenderType>agent</SenderType>
               <SenderTypeID>1</SenderTypeID>
               <Subject>Articles Subject</Subject>
               <TicketID>1376</TicketID>
               <To>OTRS Queue Name</To> <<---- This should be the customers@email-address.com
            </Article>
            <ChangeBy>5</ChangeBy>
            <Changed>2019-09-30 12:17:44</Changed>
            <CreateBy>5</CreateBy>
            <Created>2019-09-30 12:17:44</Created>
            <CustomerID />
            <CustomerUserID />
            <DynamicField>
               <Name>ProcessManagementActivityID</Name>
               <Value />
            </DynamicField>
            <DynamicField>
               <Name>ProcessManagementProcessID</Name>
               <Value />
            </DynamicField>
            <EscalationResponseTime>0</EscalationResponseTime>
            <EscalationSolutionTime>0</EscalationSolutionTime>
            <EscalationTime>0</EscalationTime>
            <EscalationUpdateTime>0</EscalationUpdateTime>
            <GroupID>1</GroupID>
            <Lock>unlock</Lock>
            <LockID>1</LockID>
            <Owner>root@localhost</Owner>
            <OwnerID>1</OwnerID>
            <Priority>3 normal</Priority>
            <PriorityID>3</PriorityID>
            <Queue>OTRS Queue Name</Queue>
            <QueueID>21</QueueID>
            <RealTillTimeNotUsed>0</RealTillTimeNotUsed>
            <Responsible>root@localhost</Responsible>
            <ResponsibleID>1</ResponsibleID>
            <SLAID />
            <ServiceID />
            <State>new</State>
            <StateID>1</StateID>
            <StateType>new</StateType>
            <TicketID>1376</TicketID>
            <TicketNumber>2019093047000171</TicketNumber>
            <Title>My Subject</Title>
            <Type>Unclassified</Type>
            <TypeID>1</TypeID>
            <UnlockTimeout>1569845864</UnlockTimeout>
            <UntilTime>0</UntilTime>
         </Ticket>
         <TicketID>1376</TicketID>
         <TicketNumber>2019093047000171</TicketNumber>
      </TicketCreateResponse>
   </soap:Body>
</soap:Envelope>
Here the wrong view of such a ticket (with some notes):
Image


I hope, i provided all neccessary information to find a smooth solution.

Thanks alot

Daniel
root
Administrator
Posts: 4250
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: GenericInterface (PHP-SOAP) does not respect TO field in article data

Post by root »

Hi,

Please add the parameter SenderType with the value agent and give it a try.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
dsepeur
Znuny newbie
Posts: 19
Joined: 30 Sep 2019, 15:05
Znuny Version: 6 community edition
Real Name: Daniel Sepeur
Company: TREND Service GmbH

Re: GenericInterface (PHP-SOAP) does not respect TO field in article data

Post by dsepeur »

Hey @all,

sorry, but this didnt work for me.
I set Var SenderType with value 'agent' but nothing changes. In the field To:, OTRS still shows me the Queue-Name instead of the customers E-Mail Address.

Is there any solution to make the Interface spend respect the To field?

Thank you so much for all hints. I really feel myself extremely idealess for the moment.

Daniel
zzz
Znuny superhero
Posts: 914
Joined: 15 Dec 2016, 15:13
Znuny Version: All
Real Name: Emin
Company: Efflux GmbH
Contact:

Re: GenericInterface (PHP-SOAP) does not respect TO field in article data

Post by zzz »

Hey Daniel,

Give it a try with SenderTypeID = 3 in the article.

Edit:
From needs to be filled with the customer information to make the reply function work (FirstName Lastname <mail@example.com>).
Adding 'ReplyTo' could also work (not tested).

Best regards
Emin
Professional Znuny and OTRS services: efflux.de | efflux.de/en/

Free and premium add-ons: German | English
dsepeur
Znuny newbie
Posts: 19
Joined: 30 Sep 2019, 15:05
Znuny Version: 6 community edition
Real Name: Daniel Sepeur
Company: TREND Service GmbH

Re: GenericInterface (PHP-SOAP) does not respect TO field in article data

Post by dsepeur »

Hi Emin,

thank you for your fast reply.
Im struggeling actually around to make my process work.
Your sugguestion to set the from address to customers address is correct, to make the OTRS reply function work. Thats absolutely correct.
And this works just for example if there is a web-form, the user put information in and send it to the system, which then raise a ticket. In this case, everything would be fine and we see then in the ticket itself the following information:

From: customers@email.de
To: Queue-Name
Subject: ....

But in fact that my request is a little different, it will not work like this. Let me explain.
There is an inhouse application which creates a case via web-form. The agent sends this form, the inhouse appliaction do something with the data and ADDITIONALLY, it should create an OTRS-ticket. So in this case, we have the situation, that we send data to the inhouse application and this application should raise a ticket with our companies email address as sender and the customers email addres as recpient. The ticket should then have the following information:

From: ourstaffmember@company.de
To: customers@email.de
Subject: ....

And exactly this does not work for me. I tried much things like creating a ticket with a default article and directly after that a ticket update with the information i need it. But no luck in this case.

Maybe there is another solution which fits to my needs.

The process diagram looks like this:

Agent calls the inhouse application.
Agent provides data from customer.
Agent sends the data to the inhouse application.
Inhouse application save data.
Inhouse application raise a ticket in the name of the customer (From: ourstaffmember@company.de, To: customers@email.de, Subject: ...)
Inhouse application gets the TicketNumber from the new ticket
Inhouse applications sends a nice email out to the customer

This process is requested from some higher sitting guys here :(

So if you want, you can say, that in this case, the OTRS-System has the functionality to track what we send. It just dont do it like i want :lol:

Maybe someone out there has an idea how to solve this issue.

Thanks alot to all guys breaking their mind with me ...

Daniel
zzz
Znuny superhero
Posts: 914
Joined: 15 Dec 2016, 15:13
Znuny Version: All
Real Name: Emin
Company: Efflux GmbH
Contact:

Re: GenericInterface (PHP-SOAP) does not respect TO field in article data

Post by zzz »

Oh, thanks for making that clear (I guess it was clear the whole time :( ), forget everything I said.

The GenericInterface-TicketCreate code doesn't seem to fully support the ArticleCreate API.

The Article->To key gets ignored. You have to make some code changes to support it.

Kernel/GenericInterface/Operation/Ticket/TicketCreate line 1420
Original:

Code: Select all

    # set Article To
    my $To;
    if ( $Ticket->{Queue} ) {
        $To = $Ticket->{Queue};
    }
    else {
        $To = $Kernel::OM->Get('Kernel::System::Queue')->QueueLookup(
            QueueID => $Ticket->{QueueID},
        );
    }
Needs to be:

Code: Select all

    # set Article To
    my $To;
    if ( $Article->{To} ) {
        $To = $Article->{To};
    } 
    elsif ( $Ticket->{Queue} ) {
        $To = $Ticket->{Queue};
    }
    else {
        $To = $Kernel::OM->Get('Kernel::System::Queue')->QueueLookup(
            QueueID => $Ticket->{QueueID},
        );
    }
That alone, however, won't make the reply function work. You also need to make this change (or you just make this change if it's ok that the 'To' field is filled with the queue name):

Kernel/GenericInterface/Operation/Ticket/TicketCreate line 1461

Add this line:

Code: Select all

        ReplyTo              => $Article->{To} || '',
Best regards
Emin
Professional Znuny and OTRS services: efflux.de | efflux.de/en/

Free and premium add-ons: German | English
dsepeur
Znuny newbie
Posts: 19
Joined: 30 Sep 2019, 15:05
Znuny Version: 6 community edition
Real Name: Daniel Sepeur
Company: TREND Service GmbH

Re: GenericInterface (PHP-SOAP) does not respect TO field in article data

Post by dsepeur »

Hi Emin,

i will give it a shot later. For the moment im not able.
But you will get a feedback. Even you are my lifesaver or not. I swear :lol:

Thank alot until here

Daniel
dsepeur
Znuny newbie
Posts: 19
Joined: 30 Sep 2019, 15:05
Znuny Version: 6 community edition
Real Name: Daniel Sepeur
Company: TREND Service GmbH

[SOLVED] Re: GenericInterface (PHP-SOAP) does not respect TO field in article data

Post by dsepeur »

Hey Emin,
Hey @all,

thats exactly the hint i needed. So my problem is solved and i have to shout out a big THANK YOUUUU.

Thanks alot for all who shared my problem and helped me out in this case.

Daniel
Locked