Search code examples
drupal-7disqus

Disqus comment notification in Drupal


I have a site where users post content. I want to (somehow) send a notification to the creator of the post when someone comments with Disqus.

I know that people can subscribe to a disqus thread manually, but it's a lot better automatically because if a user is the owner of the content it's logical to send him notifications about it.

Thanks!


Solution

  • I'm not sure exactly how you would build this into Drupal, but we can approach this from a higher level. Assuming you have a way of matching the Disqus thread information to the specific author, you can take advantage of the onNewComment callback built into the embed (will probably require editing the Drupal module). There's an example in our API recipes that shows you how to do this: https://github.com/disqus/DISQUS-API-Recipes/tree/master/notifications

    Essentially it follows this sequence:

    1. Add an event handler on your Disqus-enabled page for the onNewComment callback
    2. Call out to a server-side script that you host
    3. This script makes a request to the Disqus API for more information to help match the discussion to the author.
    4. Email is sent to the author after a match is found

    You can also skip the Disqus API call in your server-side script if you can get all the information you need using information available to the client. The callback also includes the comment content to fill the notification body, but nothing about the author of the comment.