one of the documented procedures in this installation of the ACS
chat_last_personal_post   chatter_id
What it does:
Returns a Tcl list of the time and user id of the last personal message between currently connected user and argument-specified user
Defined in: /web/philip/tcl/chat-defs.tcl

Source code:

    set user_id [ad_verify_and_get_user_id]
    set db [ns_db gethandle subquery]

    set selection [ns_db select $db "select to_char(creation_date,'HH24:MI:SS') as time, creation_user
from chat_msgs
where (creation_user = $chatter_id
       and recipient_user = $user_id)
   or (creation_user = $user_id 
       and recipient_user = $chatter_id)
order by creation_date desc"]

    ns_db getrow $db $selection

    ns_db flush $db
    ns_db releasehandle $db
    regsub -all ":" $time "" time
    return [list $time $creation_user]