This guide will only cover low level basic way to do TWI/I2C comms as a "single slave device".
The question about "How if something happens when TWI/I2C lines get disconnected or interrupted by other slave device or else to do with trouble in the lines"
will be consider as the next level problem.
You should be able to do the "master device" things before you try this or you'll end up in confusion.
Forgive me if I typed wrong grammar or unusual word, just simply tell me and I'll edit it.
TWI/I2C hardware is interrupt base which give us ease to do the TWI/I2C comms as "slave device".
This will be 6 steps to do:
Step 1. Basic initial setup.
Step 2. Handling slave address.
Step 3. Checking slave address setup.
Step 4. Processing master request in ISR
Step 5. Processing received data in ISR
Step 6. Processing data to transmit in ISR