Giter VIP home page Giter VIP logo

meteor-intercom's Introduction

Meteor Intercom

A package to use Intercom.io easily with Meteor.

NOTE: Package updates are released under verso:intercom as it replaces percolate:intercom.

Installation

Intercom can be installed with Meteor's package manager:

$ meteor add verso:intercom

API

Ensure you have Meteor.settings.intercom.secret and Meteor.settings.public.intercom.id defined to the values provided to you by Intercom. Also define Meteor.settings.intercom.apikey if you intend to use Intercom on the server side.

Some Intercom subscription packages allow for anonymous users. To enable the use of anonymous users, set Meteor.settings.public.intercom.allowAnonymous to true.

By default, the package will send up the user's id, creation date, and hash (if defined, see below). To send custom data, set:

IntercomSettings.userInfo = function(user, info) {
  // add properties to the info object, for instance:
  if (user.services.google) {
    info.email = user.services.google.email;
    info['name'] = user.services.google.given_name + ' ' + user.services.google.family_name;
  }
}

email and name are preset fields provided by Intercom. You may add any additional custom user attribute.

If you need to wait on a user subscription for e.g. the hash to come down, you can return false in your userInfo function to tell the package to wait.

IntercomSettings.userInfo = function (user, info) {
  if (!user.intercomHash) {
    return false; // the hash isn't loaded to the users collection yet. come back later.
  }
  // ...
}

If you want to add fields sent to intercom for an anonymous user, you can add them through in the anonymousInfo function.

IntercomSettings.anonymousInfo = function ( info ) {
  // check all router subscriptions have loaded
  if (!Router.current() || !Router.current().ready())
    return false;

  info.anonymous = true;
  return;
};

On the server, you can also interact with the Intercom API via the official intercom-node client.

// Create an event for a user
IntercomClient.events.create({
  event_name: 'Test event',
  created_at: Math.floor(new Date().getTime()/1000),
  user_id: '<Insert meteor user id>'
}, function (d) {
  console.log(d);
});

Notes

This package will automatically subscribe the current user to the currentUserIntercomHash publication which will add an intercomHash property to your user documents enabling the use of intercom's secure mode.

License

MIT. (c) Percolate Studio, maintained by Tom Coleman (@tmeasday)

Meteor Intercom was developed as part of the Verso project.

meteor-intercom's People

Contributors

alxbck avatar dandv avatar dburles avatar hanchang avatar julie-is-late avatar npvn avatar shelkie avatar timbotnik avatar tmeasday avatar zol avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.