In a Self script the conversation is available in the "conversation" variable.
To access the conversation object's id you can use,
For a complete list of object methods see,
Depending on the type of conversation, there are also other ids available. Chat conversations have a #gid attribute and some social media and IOT conversations have an #id attribute.