Giter Site home page Giter Site logo

vue-intercom's Introduction

vue-intercom

A reactive wrapper for Intercom's JavaScript API

Forked in order to add the showArticle command.

Installation

npm install --save @charminder/vue-intercom

yarn add @charminder/vue-intercom
import Vue from 'vue';
import VueIntercom from '@charminder/vue-intercom';

Vue.use(VueIntercom, { appId: 'your-app-id' });

Usage

vue-intercom handles the injection of Intercom's script into your html and wraps calls to the Intercom API with methods and exposes them through the $intercom object in your components.

new Vue({
  el: '#app',
  data() {
    return {
      userId: 1,
      name: 'Foo Bar',
      email: '[email protected]',
    };
  },
  mounted() {
    this.$intercom.boot({
      user_id: this.userId,
      name: this.name,
      email: this.email,
    });
    this.$intercom.show();
  },
  watch: {
    email(email) {
      this.$intercom.update({ email });
    },
  }
});

Example App

cd example
yarn
yarn dev

API

Values

$intercom.ready

Set to true once the Intercom script has been loaded.

$intercom.visible

Set via the onShow/onHide events.

$intercom.unreadCount

Set via the onUnreadCountChange event.

Methods

$intercom.boot(/* optional */options)

Calls Intercom('boot'). Automatically sets the app_id unless specified in the options object.

$intercom.shutdown()

Calls Intercom('shutdown').

$intercom.update(/* optional */options)

Calls Intercom('update'). If the options object is set, calls Intercom('update', options)

$intercom.show()

Calls Intercom('show').

$intercom.hide()

Calls Intercom('hide').

$intercom.showMessages()

Calls Intercom('showMessages').

$intercom.showNewMessage(/* optional */content)

Calls Intercom('showNewMessage') with pre-populated content if provided.

$intercom.trackEvent(name, /* optional */metadata)

Calls Intercom('trackEvent') with extra metadata if provided.

$intercom.showArticle(articleId)

Calls Intercom('showArticle', article).

$intercom.getVisitorId()

Calls Intercom('getVisitorId').

License

MIT

Copyright (c) 2017 Continuon

vue-intercom's People

Contributors

charminder avatar dependabot[bot] avatar johnnynotsolucky avatar simsteve7 avatar williamchong 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.