Skip to content

Instantly share code, notes, and snippets.

@Furzel
Created February 3, 2015 21:00
Show Gist options
  • Save Furzel/747b69236ad2923a27a7 to your computer and use it in GitHub Desktop.
Save Furzel/747b69236ad2923a27a7 to your computer and use it in GitHub Desktop.
intercom update on new message
function updateMessageActivity(message, date, done) {
message.company.listTeam(function (err, teammates) {
if (err)
return done(err);
var user = (message.author) ? message.author : teammates[0],
now = Math.floor(date/1000);
var intercomData = {
email: user.email,
company: {
id: message.company.id,
last_received_at: now
}
};
if (message.author) {
intercomData.company.last_activity_at = now;
intercomData.last_activity_at = now;
}
intercom.updateUser(intercomData, done);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment