Get MacBook to say Thank You when plugging in the power cord?
This worked for me:

global thanks

on run
    set thanks to false
end run

on idle
    set battStatus to do shell script "pmset -g | grep \\*"
    if battStatus contains "AC Power" then
        if thanks is false then
            say "thank you"
            set thanks to true
        end if
    else
        set thanks to false
    end if
    return 1
end idle


Open Script Editor, Save as Application, Check "Stay open after run handler" to keep the program running. The only downside is you'll have to keep this program open at all times. You can set it to launch when you login. Maybe someone else has a better way to address this.