If you use lua, you can try code like
if DEFAULT_CHAT_FRAME then
local c=DEFAULT_CHAT_FRAME:GetNumMessages()
for i=1,c do
local msg = DEFAULT_CHAT_FRAME:GetMessageInfo(i)
if msg then
YOUR CODE HERE
end
end
end
If message are display in WRobot tab "Chat" you can also use wrobot class Channel (sample: https://wrobot.eu/forums/topic/4802-mage-portal-bot/ )