there are lots of examples on this forum as chike said, but the basic logic behind it is that first you get the last line of text recived in the room chat window and if that line of text has your defined trigger(for example !MyTrigger) then call the function or procedure to send a responce(usually as text or link in your example). So to sum it up you need 3 function… 1 to get the last line of text, 2 to check if the line contains your trigger, 3 send text back to messenger.
Hope that helps you understand how they do it, look at the example codes in the forum for more details on to make these functions