AutoResponse#

NAME#

Kernel::System::AutoResponse - auto response lib

DESCRIPTION#

All auto response functions. E. g. to add auto response or other functions.

PUBLIC INTERFACE#

new()#

create an object

my $AutoResponseObject = $Kernel::OM->Get('Kernel::System::AutoResponse');

AutoResponseAdd()#

add auto response with attributes

my $AutoResponseID = $AutoResponseObject->AutoResponseAdd(
    Name        => 'Some::AutoResponse',
    ValidID     => 1,
    Subject     => 'Some Subject..',
    Response    => 'Auto Response Test....',
    ContentType => 'text/plain',
    AddressID   => 1,
    TypeID      => 1,
    UserID      => 123,
);

AutoResponseGet()#

get auto response with attributes

my %Data = $AutoResponseObject->AutoResponseGet(
    ID => 123,
);

AutoResponseUpdate()#

update auto response with attributes

my $Success = $AutoResponseObject->AutoResponseUpdate(
    ID          => 123,
    Name        => 'Some::AutoResponse',
    ValidID     => 1,
    Subject     => 'Some Subject..',
    Response    => 'Auto Response Test....',
    ContentType => 'text/plain',
    AddressID   => 1,
    TypeID      => 1,
    UserID      => 123,
);

AutoResponseDelete()#

deletes an auto response from the database by it’s id

$AutoResponseObject->AutoResponseDelete(
    ID     => 1,
    UserID => 1,
);

AutoResponseExport()#

export an auto response

my $ExportData = $AutoResponseObject->AutoResponseExport(
    # required either ID or ExportAll
    ID                       => $AutoResponseID,
    ExportAll                => 0,               # possible: 0, 1

    UserID                   => 1,               # required
}

returns AutoResponse hashes in an array with data:

my $ExportData =
[
    {
        'ContentType' => 'text/plain',
        'ChangeTime' => '2024-07-16 13:17:20',
        'Address' => 'some-mail@outlook.com',
        'ValidID' => 1,
        'Type' => 'auto reject',
        'Queues' => {},
        'TypeID' => 2,
        'Subject' => 'Your email has been rejected! (RE: <OTRS_CUSTOMER_SUBJECT[24]>)',
        'AddressID' => 1,
        'Name' => 'default reject (after follow-up and rejected of a closed ticket)',
        'CreateBy' => 1,
        'Response' => 'Your previous ticket is closed.

– Your follow-up has been rejected. –

Please create a new ticket.

Your Znuny Team ‘,

‘Comment’ => ‘’, ‘ChangeBy’ => 1, ‘ID’ => 587, ‘CreateTime’ => ‘2024-07-16 13:15:50’

}, {

‘ContentType’ => ‘text/html’, ‘ChangeTime’ => ‘2024-07-16 13:16:27’, ‘Address’ => ‘some-mail@outlook.com’, ‘ValidID’ => 1, ‘Type’ => ‘auto follow up’, ‘Queues’ => {}, ‘TypeID’ => 3, ‘Subject’ => ‘RE: <OTRS_CUSTOMER_SUBJECT[24]>’, ‘AddressID’ => 1, ‘Name’ => ‘default follow-up (after a ticket follow-up has been added) (copy)’, ‘CreateBy’ => 1, ‘Response’ => ‘Thanks for your follow-up email<br />

<br /> You wrote:<br /> &lt;OTRS_CUSTOMER_EMAIL[6]&gt;<br /> <br /> Your email will be answered by a human ASAP.<br /> <br /> Have fun with Znuny!<br /> <br /> Your Znuny Team’,

‘Comment’ => ‘’, ‘ChangeBy’ => 1, ‘ID’ => 590, ‘CreateTime’ => ‘2024-07-16 13:16:27’

}

];

AutoResponseImport()#

import an auto response via YAML content

my $ImportResult = $AutoResponseObject->AutoResponseImport(
    Content                        => $YAMLContent, # mandatory, YAML format
    OverwriteExistingAutoResponses => 0,            # optional, possible: 0, 1
    UserID                         => 1,            # mandatory
);

Returns:

$Result = {
    Success          => 1,                                  # 1 if success or undef if operation could not
                                                            # be performed
    Message          => 'The Message to show.',             # error message
    Added            => 'AutoResponse1, AutoResponse2',     # string of AutoResponses correctly added
    Updated          => 'AutoResponse3, AutoResponse4',     # string of AutoResponses correctly updated
    NotUpdated       => 'AutoResponse5, AutoResponse6',     # string of AutoResponses not updated due to existing entity
                                                            # with the same name
    Errors           => 'AutoResponse5',                    # string of AutoResponses that could not be added or updated
    AdditionalErrors => ['Some error occured!', 'Error2!'], # list of additional error not necessarily related to specified AutoResponse
};

AutoResponseCopy()#

copy an auto response without linking it to any queue

my $NewAutoResponseID = $AutoResponseObject->AutoResponseCopy(
    ID     => 1, # mandatory
    UserID => 1, # mandatory
);

AutoResponseGetByTypeQueueID()#

get a hash with data from Auto Response and it’s corresponding System Address

my %QueueAddressData = $AutoResponseObject->AutoResponseGetByTypeQueueID(
    QueueID => 3,
    Type    => 'auto reply/new ticket',
);

Return:

.. code-block:: perl

my %QueueAddressData(

# Auto Response Data ‘Text’ => ‘Your ZNUNY TeamZNUNY! answered by a human asap.’, ‘Subject’ => ‘New ticket has been created! (RE: <ZNUNY_CUSTOMER_SUBJECT[24]>)’, ‘ContentType’ => ‘text/plain’, ‘SystemAddressID’ => ‘1’, ‘AutoResponseID’ => ‘1’,

# System Address Data ‘ID’ => ‘1’, ‘Name’ => ‘znuny@localhost’, ‘Address’ => ‘znuny@localhost’, ‘Realname’ => ‘ZNUNY System’, ‘Comment’ => ‘Standard Address.’, ‘ValidID’ => ‘1’, ‘QueueID’ => ‘1’, ‘CreateTime’ => ‘2010-03-16 21:24:03’, ‘ChangeTime’ => ‘2010-03-16 21:24:03’,

);

AutoResponseExportDataGet()#

get data to export auto response

my %AutoResponseData = $AutoResponseObject->AutoResponseExportDataGet(
    ID               => 1, # mandatory
);

Returns:

    my %AutoResponseData = (
        'ContentType' => 'text/plain',
        'Address' => 'main@domain.com',
        'CreateTime' => '2024-07-17 10:07:32',
        'Queues' => {
            '4' => 'Misc',
            '3' => 'Junk',
            '1' => 'Postmaster'
        },
        'TypeID' => 1,
        'Subject' => 'RE: <OTRS_CUSTOMER_SUBJECT[24]>',
        'Type' => 'auto reply',
        'ChangeTime' => '2024-07-23 10:10:07',
        'Name' => 'default reply (after new ticket has been created2)',
        'Comment' => '',
        'ValidID' => 1,
        'AddressID' => 1,
        'ID' => 915,
        'Response' => 'This is a demo text which is send to every inquiry.
It could contain something like:

Thanks for your email. A new ticket has been created.

You wrote: <OTRS_CUSTOMER_EMAIL[6]>

Your email will be answered by a human ASAP

Have fun with Znuny! :-)

Your Znuny Team ‘,

‘ChangeBy’ => 1, ‘CreateBy’ => 1

);

AutoResponseExportFilenameGet()#

get export file name based on auto response name

my $Filename = $AutoResponseObject->AutoResponseExportFilenameGet(
    Name => 'autoresponse_1',
    Format => 'YAML',
);

AutoResponseQueuesList()#

get a list of the queues that have been linked to auto response

my %AutoResponseQueues = $AutoResponseObject->AutoResponseQueuesList(
    ID => 1, # mandatory
);

Returns:

my %Queues = (
    1 => 'queue1',
    2 => 'queue2',
)

AutoResponseWithoutQueue()#

get a list of the Queues that do not have Auto Response

my %AutoResponseWithoutQueue = $AutoResponseObject->AutoResponseWithoutQueue();

Return example:

my %Queues = (
    1 => 'Some Name',
    2 => 'Some Name',
);

AutoResponseList()#

get a list of the auto responses

my %AutoResponse = $AutoResponseObject->AutoResponseList(
    Valid   => 1,                 # (optional) default 1
    TypeID  => 1,                 # (optional) Auto Response type ID
);

Return example:

my %AutoResponse = (
    '1' => 'default reply (after new ticket has been created)',
    '2' => 'default reject (after follow up and rejected of a closed ticket)',
    '3' => 'default follow up (after a ticket follow up has been added)',
);

AutoResponseTypeList()#

get a list of the Auto Response Types

my %AutoResponseType = $AutoResponseObject->AutoResponseTypeList(
    Valid => 1,     # (optional) default 1
);

Return example:

my %AutoResponseType = (
    '1' => 'auto reply',
    '2' => 'auto reject',
    '3' => 'auto follow up',
    '4' => 'auto reply/new ticket',
    '5' => 'auto remove',
);

AutoResponseQueue()#

assigns a list of auto-responses to a queue

my $Success = $AutoResponseObject->AutoResponseQueue(
    QueueID         => 1,
    AutoResponseIDs => [1,2,3],
    UserID          => 1,
);

AutoResponseQueueLinkByAutoResponse()#

assigns a list of queues to a auto response

my $Success = $AutoResponseObject->AutoResponseQueueLinkByAutoResponse(
    QueueIDs => [1,2,3],
    ID       => 1,
    UserID   => 1,
);

_NameExistsCheck()#

return if another auto-response with this name already exits

$AutoResponseObject->_NameExistsCheck(
    Name => 'Some::AutoResponse',
    ID   => 1, # optional
);