Future website

How do i add IM feature to a website I’m
Planning on making similar to Facebook.

There are several ready made open source chat scripts that are free for anybody to download and use, a Google search is probably a good place to start.

There are several chat widgets available online. You have to just modify it as per your requirement and that’s it. One of the best which i used is “Chatango”. It is very user friendly and easy to implement in website. Also, you can define various administrator and moderators in it and give them various privileges as per their role. You can find it by here - http://chatango.com/