Email automation with followups example

In order to setup automatic followups:

Step 1: Navigate to Configuration>Automation>Tags>Create tags (one tag for each followup message)

Example: 1. Auto-followup, 2. Auto-followup (two followup messages)

Step 2: Navigate to Configuration>Automation>Rules>Create rule that will apply when ticket status is changed, old status is answered, new status is open and ticket tags contain the first tag you created (1. Auto-followup). Fill in the same conditions for the second tag. Choose perform "action remove tag" (1. Auto-followup, 2. Auto-followup).

Step 3: Navigate to Configuration>Automation>Time rules>Create time rule that will apply when ticket status change is older than for example 3 days, ticket status is answered and ticket tags contain the first tag you created (1. Auto-followup). Choose perform action “send answer” and fill in from, subject, message fields. At the end choose "remove tag" (1. Auto-followup) and "add tag" (2. Auto-followup).

Step 4: Create the second time rule that will apply when ticket status change is older than for example 13 days, ticket status is answered and ticket tags contain the second tag you created (2. Auto-followup). Choose perform action "send answer" and fill in from, subject, message fields. At the end choose "remove tag" (2. Auto-followup) and "resolve ticket".

You can also automatically import subsribers for your automation workflow via API.

Below is a php script that allows you to import contacts to your LiveAgent and send them the first message and followup according to defined tag.

<?php
const API_KEY = ‘yourapikey’;
const APP_URL = 'https://yourliveagentdomain/api';

function createTicket($name, $email) {
    $ch = curl_init();
    $curl_post_data = array(
            /* These are mandatory params */
            'message' => ‘message’,
            'useridentifier' => ‘yourliveagentloginemail’,
            'department' => 'departmentcode, example: 9ce92e92',
            'subject' => ‘subject’,
            'recipient' => $email,
            'apikey' => API_KEY,
            'do_not_send_mail' => 'N',
            /* ...and these are optional */
            'recipient_name' => $name,
            'status' => 'A',
            'is_html_message' => 'Y',
    );
    curl_setopt($ch,CURLOPT_URL,APP_URL . "/conversations");
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $curl_post_data);
    $curl_response=curl_exec($ch);
    if ($curl_response === false) {
        $info = curl_error($ch);
        curl_close($ch);
        die("error occured during curl exec. Additioanl info: " . var_export($info));
    }
    curl_close($ch);
    $data = json_decode($curl_response, true);
print_r($data);
    //assign tag
    $ch = curl_init();
    $curl_post_data = array(
            /* These are mandatory params */
            'apikey' => API_KEY,
            /* ...and these are optional */
            'name' => ‘nameofyourtag’,
    );
    curl_setopt($ch,CURLOPT_URL,APP_URL . '/conversations/' . ($data['response']['conversationid']) . '/tags');
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $curl_post_data);
    $curl_response=curl_exec($ch);
print_r($curl_response);
}

//name, email columns
if (($handle = fopen("customers.csv", "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        print_r($data);
                createTicket($data[0], $data[1]);
    }
fclose($handle);
}

Import your contacts to csv file named customers.csv like this:

Name1,name1@example.com
Name2,name2@example.com
Name3,name3@example.com
and run the script with a Command Console/Terminal (interface in which you can type and execute text based commands).
×