QA Graphic

Time based Greetings in Slack


I spend a lot of time communicating with some remote teams. Most of the conversation is done in Slack. Recently I thought of a cool way to implement TextExpander and Slack.

When I start the conversation, I usually do it first thing in the morning with 'Good Morning Champion.' The problem is that in the remote offices it could be afternoon or evening so the greeting is a bit strange. That's when I thought that TextExpander could make the greeting more friendly.

I created several location base snippets that would enter in the proper time greetings based on their location.

Real World Example

There is a snippet in my library for 'in.hello' and this will automatically display the correct greetings when I am talking to my India team in chat. So if it's night time, it would say 'Good Evening Champion' and if it's before 6 pm their time, 'Good Afternoon Champion.' I have sfo.hello, Japan.hello and Korea.hello.

Now I will always say the correct greetings and not have to think about it.

This is the PHP code that I use to get that done:

India Hello Examples

function greeting(){
    $timeOfDay = date('H');
    if($timeOfDay > '17'){
        return 'Good evening Champion. ';
    } else if ($timeOfDay > '12'){
        return 'Good afternoon Champion. ';
    } else {
        return 'Good morning Champion. ';
echo greeting();

I used the PHP Date functionality and not the built in date tools in TextExpander because of portability. I can travel to any time zone and not have to worry about what my system clock says, the greeting will always be correct.



Add Comments




I find TextExpander, by Smile on My Mac, to be an awesome productivity tool. This past winter, I posted some cool snippets that demonstrate the power of the application. Occasionally, I will post some new snippets that I think will be useful in anyone's TextExpander library.


SaturdayInternet Tools
SundayOpen Topic
Monday Media Monday
WednesdaySnagIt for QA