Installing Intercom chat service into TutorCruncher

This article describes the process of adding Intercom to TutorCruncher for messaging between admins and other roles using custom JavaScript

Tom Hamilton Stubber avatar
Written by Tom Hamilton Stubber
Updated over a week ago

This tool allows your users (clients, tutors, students etc) to chat to admins using Intercom. Your admins will need to sign up to Intercom and monitor their inbox from there, not from inside TutorCruncher. It is not for tutors/clients/students to talk to each other, though that is on our roadmap.

Adding Intercom to TutorCruncher is easy using Custom JavaScript:

  1. Simply sign up for an account with Intercom.

  2. Find your app id.

  3. Inside TutorCruncher, go to System > Settings > Custom JavaScript and enter the following template.

  4. Customise your options using the instructions inside the template, including limiting who can access the chat tool.

  5. Click "Save", and then you will be able to test the tool in your Demo Branch. Once you're satisfied that's working you can click "Send for review".

  6. A member of the team will review your code to make sure it's correct and then approve it, normally within a few working hours.

That's it!

Here is the code that you need to copy into the form for adding custom JavaScript. Don't forget to follow the two customisation steps described!

This tool will allow you to add Intercom to TutorCruncher so that some or all of your users will be able to contact admins through
the external chat service. This is only for users to chat to admins, not to talk to each other. That isn't possible with TutorCruncher
currently, though it is on our roadmap.

There are two small steps to the set up process.

1. Enter your app_id inside the quotation marks below where it says

const app_id = "YOUR_APP_ID"

2. Choose who can access the Intercom chat function. Setting the value to "true" (without quotation marks) will mean
that the role type will be able to use the chat function. For instance, setting

const tutors_can_access = true

means that tutors can use the chat function. Remember, this only means that tutors can talk to admins using Intercom, not
students/clients/other roles.

const app_id = "YOUR_APP_ID"

const tutors_can_access = true
const clients_can_access = false
const students_can_access = false
const affiliates_can_access = false


const role_data = JSON.parse($('#head-data').text()).raven_data

const access_role_types = []
if (tutors_can_access) {
if (clients_can_access) {
if (students_can_access) {
if (affiliates_can_access) {

if (access_role_types.includes(role_data.role)) {
const render_data = JSON.parse($('#render-data').text())
const intercom_data = JSON.parse($('#intercom-data').text())

function create_user_hash(str) {
let hash = 0;
for (let i = 0, len = str.length; i < len; i++) {
let chr = str.charCodeAt(i);
hash = (hash << 5) - hash + chr;
hash |= 0;
return hash;

const user_id = `${role_data.role}-${}-${}`
intercomSettings = {
api_base: "",
app_id: app_id,
user_id: user_id,
user_hash: create_user_hash(user_id),
name: render_data.user_full_name,
(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src=`${app_id}/`;var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(document.readyState==='complete'){l();}else if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})();
Did this answer your question?