Let a user click the timestamp to the left of the messages (or a "#" or other symbol), which inserts something like this into the reply box:
> Replying to username:
Then your message you send ends up looking like:
> Reply to username: I agree!
Clicking on "Reply to username" or just the username could scroll back the chat and highlight the message you replied to.