Git Product home page Git Product logo

chatra's Introduction

Chatra logo

🚩 This package is intended for developers. If you just want to add Chatra to your website, check our Installation guides for popular e-commerce platforms and content management systems or just add a small code snippet to your website.

Official Chatra module

This module loads the Chatra widget and passes method calls to the Javascript API.

Key Features:

  • Easy integration with your website or web app
  • Works perfectly with React, Angular, Vue, and other frameworks
  • Uses ES5 for maximum compatibility, doesn’t require transpiling.

Installation

To add the chat widget to your website or web app, sign up with Chatra.

If you already have an account, install the package using your favorite package manager:

$ npm install @chatra/chatra
$ yarn add @chatra/chatra

Configuration

Step 1. Go to the Preferences section of your Chatra dashboard and copy the Public key.

Step 2. Initialize the widget in your index.js or root controller

index.js

let Chatra = require('chatra')

let config = {
    ID: 'Paste your Public key here'
}

Chatra('init', config)

🚩 You can customize the chat and button appearance, localization, and lots of other settings by passing setup to the initialization config. Please check the Javascript API documentation for details.

index.js

let config = {
    setup: {
        buttonSize: 75
    },
    ID: 'Paste your ChatraID here'
}

Moreover, you can pass arbitrary visitor info using the integration key:

index.js

let config = {
    integration: {
        name: 'Cowardly Lion',
        email: '[email protected]',

        /* any number of custom properties */
        'What does he do': 'Goes to Oz with his friends'
    },
    ID: 'Paste your ChatraID here'
}

Step 3 (optional). Call PageView to enable Targeted chats & triggers.

If your website or web app loads pages dynamically and updates the document’s URL without requiring a full page load, call the following method whenever the page changes to track these views and see them in the Chatra dashboard:

Chatra('pageView')

We recommend calling this method in your router or page controllers.

Advanced Usage

Updating the settings

You can update the settings after initialization by calling Chatra('init', config) again, which will restart Chatra with the new settings applied.

Methods

Methods are used to dynamically change the behavior of the chat widget. Methods can be called anywhere after the widget initialization, for example:

Chatra('expandWidget')

All method calls made before Chatra finished loading are put into a queue and executed when Chatra is ready.

Contact us

If you have any questions, feel free to contact us.

chatra's People

Contributors

dependabot[bot] avatar vrizo avatar wilddeer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

chatra's Issues

TypeScript Support

It's nice that you already have an npm package. Some typings for TS will be helpful. Thanks!

get new messages counter/tip on page load

Hi! I am working on a custom chat button inside sidebar
And looking for some api reference to check if there are some new messages appeared til last page load
Something like onNewMessage callback, just to show some visual tip for user, but on init

Chat window is not visible on mobile WebKit

Initially noticed it with this npm package, but it seems as though this is reproducible even with vanilla src method.

Demo

Recorded a quick video here.

Repro

  1. In any environment, even just in an index.html include Chatra's starting script PLUS the customWidgetButton prop so that default chat button is hidden:
<script>
    (function(d, w, c) {
        w.ChatraID = 'your_id';
        var s = d.createElement('script');
        w[c] = w[c] || function() {
            (w[c].q = w[c].q || []).push(arguments);
        };
        s.async = true;
        s.src = 'https://call.chatra.io/chatra.js';
        if (d.head) d.head.appendChild(s);
    })(document, window, 'Chatra');

    window.ChatraSetup = {
	   customWidgetButton: '.custom-chat-button'
	};
</script>

<button
	class="custom-chat-button"
	onclick="Chatra('openChat', true)"
>
	Open chat
</button>
  1. Important: open this file in a mobile WebKit browser. The function works fine if you're using the desktop viewport, but does not on mobile one. I was able to reproduce it in both iOS 16 and desktop Safari 16.4, though you can get more info from the desktop Safari console for some reason.
  2. Click on the Open chat button.

Expected

Chat window to open.

Result

Looking through the inspector, I can see that the chatra--safari gets chatra--expanded class, though visually nothing changes.

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.