How to... email auto responders?

JackGoa

Member
Hi all, I need to setup two auto responders to go out to people that have signed up to a list on one of my sites.

I've read every thread I can find on the forum and am even more confused than before as everyone does something different.

This is what I want to accomplish:
User signs up, if he does not respond in say 5 days (and status is changed), he gets a reminder and a field gets updated saying he got the reminder. Then if he still does not come back, then about a week later he should get one more final reminder and the "reminder column" should be updated again so he does not get another email.

So, I have the cron php plugin and cron email plugin installed. And I don't have a clue as to how to carry on. The PHP plugin has 3 options? a script, a "before option" and a php field?

The email only asks what list to run it on, but I don't really get what it does, there's also no place to add an article template for the email?

Please would someone be so kind as to point me in the right direction?

I know I need to somehow run through the user list and check their 'status' and date? And then somehow email them one by one based on the results?
 
You'd need to write that as a PHP plugin.

When you say "if he does not respond", what do you mean? Respond to an email? Log in to the site?

-- hugh
 
Morning Hugh. I think I might have told you about this lead generation/CRM thing I have been working on?

Anyway, the process is this:
- Client submits details, receives an email that requires them to forward some info to my client
- Every few days, I login, check the new leads, then manually send them a follow up email if they have not responded. I then update a field that says "follow up sent". (this I want to automate)
- If they still do not respond after a week, they need to get one more final follow up email and then I'll probably update that same field saying "final follow up sent". (also want to automate this)
- And then finally after a week, there is a field that should be updated to say "no go" should they still not have responded. (to be automated)

Obviously, if they did respond and I manually intervened and updated any of those fields, they won't be getting the auto responders.

- How does the email plugin work? Does it go through a list of emails and send them out one by one? Like a loop?
- Can I put the {tablename___elementname} in the 'to' field?
- The condition I suppose would be my php code to check the 'status' of the client and whether they should receive an email?
- Can I use an article template for the email?
- Update would then be obvious I'm guessing, I just update the relevant field after it has been sent?

Would it be better to use the PHP plugin? But then I would not know how to actually send the email? And I'm not sure how to work those 3 fields? Script, Setup, Code?

Hope I'm being clear enough?

PS, I see there is a SMS plugin. Can that be incorporated into something like this?
 
http://fabrikar.com/forums/index.php?wiki/email-scheduled-task/
so

- How does the email plugin work? Does it go through a list of emails and send them out one by one? Like a loop?
It's looping through your list
- Can I put the {tablename___elementname} in the 'to' field?
yes
- The condition I suppose would be my php code to check the 'status' of the client and whether they should receive an email?
yes
- Can I use an article template for the email?
no, but you can put HTML into the message (maybe you could fetch an article via PHP, I never tried)
- Update would then be obvious I'm guessing, I just update the relevant field after it has been sent?
use "update" options

See also the tooltips in the plugin
 
- Can I use an article template for the email?
no, but you can put HTML into the message (maybe you could fetch an article via PHP, I never tried)

Yes, we have a helper for that, FabrikHelperHTML::getContentTemplate() ...

Code:
    /**
    * Get content item template
    *
    * @param   int     $contentTemplate Joomla article id
    * @param    string $part            which part, intro, full, or both
    * @param   bool    $runPlugins      run content plugins on the text
    *
    * @since   3.0.7
    *
    * @return  string  content item html
    */
    public static function getContentTemplate($contentTemplate, $part = 'both', $runPlugins = false)

So yes, you could use an eval'ed msg, and include your own template. You'd have to do your own placeholder replacement though, as we do that before we do any eval'ing of the msg.

So something like ...

Code:
$myTmpl = FabrikHelperHTML::getContentTemplate(123, 'both', true);
return $w->parseMessageForPlaceHolder($myTmpl, $row);

... would get article 123, concatenating the intro and body of the article, run any content plugins, then do placeholder replacement. $w and $row are already defined in the plugin code that calls your code.

-- hugh
 
Hi Hugh. Ok that's some advanced stuff you have there, I'll get back to that still.

For now I setup a test list to see if I can get this to work. It seems to work if I run it manually, but not on it's own. I notice in the wiki it mentions a Cron System Plugin, but I can't find anything by that name in the downloads? I already have the email and php cron plugin installed, am I missing something?

Attached are screenshots of my test so far. (I crossed out my email address before the screenshot)

What am I going to do to update more than one field? I added a "last modified date" field for the next step where I am going to try figure out when to send the reminder.
 

Attachments

  • a_screenshot_08.jpg
    a_screenshot_08.jpg
    69.3 KB · Views: 255
  • a_screenshot_09.jpg
    a_screenshot_09.jpg
    10.8 KB · Views: 247
I think the cron system plugin is now part of the Fabrik core package, so it should already be in your plugins list in J!, just needs enabling. It's actually called "System - Fabrik Scheduled Tasks".

The email cron plugin only allows for one element to update.

If you need to do more, you'll need to roll your own PHP plugin. Which wouldn't be that hard, as we provide a helper function for sending mail.

-- hugh
 
Thanks Hugh! Got it. And it worked.

Ok, so I'm going the wrong route completely by using the email plugin. Do you perhaps have any real life examples I can look at? I'm battling to wrap my head around how to do all the updating and how to figure out when to send.

(I'm busy trying to find a thread I saw yesterday where you gave someone a calculation example to figure out the timeframe.)
 
Well, the email plugin has limitations. You can create a condition to see whether it should run (presumably based on a date element, and a "email sent" element). And you can update one element when the email is sent.

If you have two distinct emails you need to send (follow up, final follow up), then you could do that in two email plugins, with different conditions, and different update elements.

So if you don't feel like coding it all up by hand in a PHP cron plugin, I'd go that route. Work on them as entirely separate plugins.

-- hugh
 
Yes, that was what I was thinking as I just realised, I have no cooking clue how to write this code. The problem is, I can update one field and say, yes, ok, the person has not received the email, send the email and update the field to yes, but, then I also need to update the last_modified_date field so that I can make it send 5 days later, or 10 days or whatever the case may be.

This is me just trying to stop that email from sending now (don't laugh, please! :/ )

$db = JFactory::getDbo();
$query = $db->getQuery(true);

$query->select('followed_up')->from('dev_test')
->where('follow_up = 'no'));

$db->setQuery($query);

$result = $db->loadResult();

if $result == "no"{
return true;
}else{
return false;
}
 
If that's the code you have in your condition, then no. You can use placeholders ...

Code:
return '{dev_test___followed_up}' == 'no';

However ... I would suggest a different approach, and that you use pre-filters on a copy of your list to select which rows to use. Copy the list, and create the necessary prefilters to only select those which haven't been followed up on, and which fall in the right date range.

-- hugh
 
OMFingG! This did the trick:

return '{dev_test___followed_up_raw}'=='no'; (for some reason I had to add the _raw part to get it to work) without all the rest of that mumbo jumbo I had above.

WTH! lol. So, can't I then add an AND or && to that statement to check another condition?

I still can't find where you gave that guy that code to calculate the time that has expired.

If I used the PHP plugin, how would I then send the mail?
 
lol! I just figured it out as I hit send your message came through!

Hugh, to be honest, I don't really understand what you're saying above? My list keeps getting longer. So must I run a cron to duplicate it first? And I don't really understand the prefilter part at all.
 
I really need to figure this thing out. In the future I want to build a larger auto responder where users get assigned roles and they receive emails based on which role they have been assigned and the last email they received.

*and possibly purchases they have made...
 
this is a personal project for now until i make money from it, i have to fight it out before i can pay anyone :(

if i can figure out how to work out the time difference, would i be able say, something like,

return '{dev_test___followed_up_raw}'=='no' AND $timediff > 5;

?
 
Yes ...

Code:
$date1 =new DateTime();
$date2 =new DateTime('{yourtable___yourdate}');
$timediff = $date2->diff($date1)->format("%a");

... would get you the difference between today and yourdate.

-- hugh
 
Thanks Hugh! I was just going through some forums, but they're all so vague.

Ok, so,

$date1 =new DateTime();
$date2 =new DateTime('{dev_test___date_time}'); (what about the hours, minutes and seconds?)
$timediff = $date2->diff($date1)->format("%a");

return '{dev_test___followed_up_raw}'=='no' AND $timediff > 5;

should do the trick?

Because then this one becomes simple, I can have two email crons as you mentioned before. The first one sends on these conditions, then it updates that field, so they won't receive this email again, but they'll only receive it after 5 days. Correct?
Then I can do a second one that checks whether they have received the first email, i.e.,

return '{dev_test___followed_up_raw}'=='yes' AND $timediff > 15; (if I switch of 'raw' data in the excel spreadsheet, do I still need to add _raw to that placeholder?)

and then update another field maybe...? (which if I have this right, I don't think would be necessary except for admin purposes at a glance)
 
You'd have to do a range on the first one ... && ($timediff > 5 && $timediff < 15) ... otherwise the first one would catch rows > 15 as well.

The diff() would take time into account, I think. So it would be in units of 24 hours diff between 'now' and the fulle date_time.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top