A couple weeks ago, sknebel asked whether anyone in the #indieweb channel had a chat widget on their website. I used to have a form you could fill out and it would send me an SMS to my candybar phone, and a little while after that I had a prototype of a chat widget that disappeared somewhere along the way. I thought it would be fun to resurrect that idea!
It was quite a bit of a project, but I managed to finish it all in one day! I started from scratch, wanting to implement the widget in pure Javascript with no external dependencies. Between LocalStorage, EventSource, query selectors, and a few other key pieces, the browser APIs have gotten a lot better since the last time I tried this about 7 years ago!
Now when you go to my website, you'll see a chat icon in the bottom corner if I'm online!
If I'm not online, the icon just doesn't appear. The widget knows whether I'm online thanks to a little script that runs on my computer while it's awake.
If you click the icon, a chat window will pop up and you can type into it.
On the backend, this creates a new IRC channel on my private IRC server, and sends me an invitation to join it. It also sends a message to a primary channel with some information about the visitor that just connected, including the URL of the page they were on when they clicked it, their IP address and browser user agent. I don't have any other way to establish their identity other than talking with them.
The whole project is open source, along with some pretty detailed installation instructions. In order to keep the code to a minimum, I used some server-side tools such as the nginx push-stream module.
We'll see if anyone ends up using this to get in touch with me!
The design of the chat window really reminds me of Facebook, from back when I tried Facebook :)