Go to page content

Add Chat to Your Zotonic Site

Thanks to Michael Connor's zchat, it's easy to add chat system on your Zotonic site.

Why

It is often very useful for a site to have a live support line built-in.  Another case for chat is on a social site where you'd like your members to be able to communicate in real time.

Assumptions

Readers are assumed to have Mercurial and a working Zotonic 0.6 or later system and dependencies.

How

  1. Download zchat:

    Example if Zotonic > = 0.7:

    :~$ zotonic installmodule mod_chat
    

    Example if Zotonic <= 0.6:

    :~$ hg clone https://zchat.googlecode.com/hg/ mod_chat
    
  2. Link to mod_chat from Zotonic

    a. Change to the directory in which you store your site's Zotonic modules:

    Example:

    :~$ cd ~/zotonic/priv/sites/yoursite/modules
    

    b. Assuming zchat is in your home directory, create symbolic link:

    Example:

    ...yoursite/modules$ ln -s /mod_chat
    
  3. Rebuild Zotonic, assuming zotonic.sh is the Zotonic home directory

    Example:

    .../yoursite/modules$ cd ~
    :~$ ./zotonic.sh stop
    :~$ cd zotonic
    :~/zotonic$ make
    :~/zotonic$ cd ~
    :~$ ./zotonic.sh start
    
  4. Log into your site admin page, select modules from the left hand menu. Scan down to find mod_chat. Activate it.

  5. Now you can either include chat into an existing page on your site or create a new page.

    To include chat in an existing page, find the template that formats the page in the templates directory and somewhere within the content block enter:

    {% include "_chat_box.tpl" %}
    

    To create a new page:

  6. Create a page called "Chat" with category Text. Give it the Unique name page_chat, click on the Published check box, and save.

  7. Add the following dispatch rule to your dispatch list:

    {chat, ["chat"], resource_page, [ {template, "chat.tpl"}, {id, page_chat} ]},
    

    If this is the last rule in your list, omit the trailing comma.

  8. Select modules from your admin menu and click on rescan modules.

    Now you should be able to go to <yoururl>/chat and see your chat window. You'll see Anonymous <long number> in the right-most pane. That's you.

    If your chat buddy enters the chat page, a second Anonymous <another big number> will appear.

    When you or your buddy leave the chat page, the respective Anonymous tag will disappear.

    Note that chat messages are not stored or logged. That may come with a future version of zchat.

    Say thanks to Michael.

    Happy chatting!

Troubleshooting

There are no troubleshooting steps available for this guide, but you are encouraged to share yours in the comments below or on the Zotonic Users Group.

This page is part of the Zotonic documentation, which is licensed under the Apache License 2.0.