Yes, you can use the "conversation" variable in a template in Self code.
You can also use "speaker" to access the current user's variable.
For the last phrase in the conversation,
Set set a variable on the conversation,
conversation.myproperty = "my value";
Or on the speaker,
speaker.myproperty = "my value";