Assuming this is for KotOR II, there is already a script in the game files that you can use.
Create two opening dialog node's place the one that says the "who are you?" line first then the "so your back" line second
On the node you only want to appear once (in this case "who are you?") place "c_talkedto" (Without the quotes) in the conditional #1 field in TK-102's dialog editor.
And place "a_talkedtrue" (Without the quotes) in the Script #1 field in TK-102's dialog editor.
Now when the dialog node that the scripts and conditionals are set on that node will only appear the first time you speak to him.