Has anyone attempted to write a module to implement the intercom.io feedback platform into a drupal installation?

This would involve passing a line of javascript that includes user email, user name, and a timestamp when the user's account was created to intercom.

Thanks for any help.

Comments

danoprey’s picture

In my opinion, modules are overkill for things like this.

Just paste the following after scripts in your html.tpl.php, change the !YOUR! variables and upload:

<?php global $user; ?>
<script id="IntercomSettingsScriptTag">
  var intercomSettings = {
    app_id: '!YOURAPPID!',
    email: '<?php print $user->mail; ?>',
    created_at: <?php print $user->created; ?>,
	user_hash: '<?php echo sha1('!YOURSALT!' . $user->mail); ?>'
  };
</script>
<script>
  (function() {
    function async_load() {
      var s = document.createElement('script');
      s.type = 'text/javascript'; s.async = true;
      s.src = 'https://api.intercom.io/api/js/library.js';
      var x = document.getElementsByTagName('script')[0];
      x.parentNode.insertBefore(s, x);
    }
    if (window.attachEvent) {
      window.attachEvent('onload', async_load);
    } else {
      window.addEventListener('load', async_load, false);
    }
  })();
</script>
Heine’s picture

Eeeek!

If you want to add user-supplied data to a JS script, you must convert special chars to a \u or \x escape sequence.

See https://www.owasp.org/index.php/XSS_Prevention_Cheat_Sheet#RULE_.233_-_J...

Jaypan’s picture

Just paste the following after scripts in your html.tpl.php, change the !YOUR! variables and upload:

That will work, but you've bypassed all the Drupal APIs with it, and it can cause you troubles in the future. It's also not modifiable through the admin interface.

Tart0’s picture

" It's also not modifiable through the admin interface."

It can be easily achieved with a basic settings Module configuration interface ;)

hadsie’s picture

I've just created a module to integrate with intercom.io. You can check it out here http://drupal.org/project/intercomio

I'm using this with my own web app and it's working quite well for me so far.

Cheers,
- Scott

--
My personal site - http://scotthadfield.ca