npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sk-web-compat

v4.0.1

Published

Smooch.io powered web messaging

Downloads

7

Readme

Smooch Web Messenger

Circle CI npm version Bower version

Smooch is the best way to have personal, rich conversations with people on your website or customers on any device. Our features, integrations and developer-friendly APIs empower companies to connect with their customers in a whole new way.

The Smooch Web Messenger will add live web messaging to your website or web app. Customers will be able to talk to you from your website, while you manage conversations using your favorite business systems.

  • Let your customers talk to you the way they want by seamlessly moving web chat conversations to any messaging app.
  • Sync conversations across every device and channel your customers use.
  • Build better relationships with messaging that feels and looks tailored to your website.
  • Delight your customers with the most engaging conversational experience using rich messaging.
  • Maximize development productivity with a single codebase across platforms and add more channels anytime.
  • Bring every conversation into your existing business systems. No new tool to learn. See all integrations.

Usage

Script Tag

Add the following code towards the end of the body section on your page. Placing it at the end allows the rest of the page to load first.

<script src="https://cdn.smooch.io/smooch.min.js"></script>

Initialize the plugin using this code snippet

<script>
    Smooch.init({appToken: 'your_app_token'});
</script>

Browserify and Webpack

Install from npm

npm install --save smooch

// The library also has peer dependencies. If you don't already have them in your project, go ahead and install them too

npm install --save [email protected] [email protected] react@15 react-dom@15

Require and init

var Smooch = require('smooch');

Smooch.init({appToken: 'your_app_token'});

Notes about Webpack

If you are building an isomorphic app, make sure you init the widget in client code only. It currently won't work on the server side. You'll also need to add the following to your plugins since iconv-loader doesn't work very well with webpack :

new webpack.NormalModuleReplacementPlugin(/\/iconv-loader$/, 'node-noop')

You will need to install node-noop in your project. See https://github.com/andris9/encoding/issues/16

Notes about Angular 2

Some users reported that including the Smooch Web Messenger script in their Angular 2 app would cause some problems. The workaround for that is to add it after all your scripts.

Bower

Install from bower

bower install smooch

Include in JS using preferred method and init

Smooch.init({appToken: 'your_app_token'});

API

Individual functions

init(options)

Initializes the Smooch widget in the web page using the specified options. It returns a promise that will resolve when the widget is ready.

Options

| Option | Optional? | Default value | Description | | --- | --- | --- | --- | | appToken | No | - | Your app token | | givenName | Yes | - | User's given name | | surname | Yes | - | User's surname | | email | Yes | - | User's email | | jwt | Yes | - | Token to authenticate your communication with the server (see http://docs.smooch.io/javascript/#authenticating-users-optional) | userId | Yes | - | User's id | | properties | Yes | - | An object with all properties you want to set on your user | | emailCaptureEnabled | Yes | false | Deprecated won't be supported in 4.x - Enables prompt for email after the first user's message. You can retrieve that email in Slack using /sk !profile. Forced to false if other messaging channels are enabled in your Smooch app | | soundNotificationEnabled | Yes | true | Enables the sound notification for new messages | | imageUploadEnabled | Yes | true | Enables the image upload feature. | | embedded | Yes | False | Tells the widget it will be embedded. (see Embedded section below) | | customText | Yes | See the example below | Strings used in the widget UI. You can use these to either customize the text or translate it. If something is between {}, it's a variable and needs to stay in your customized text if you want to use it. |

var skPromise = Smooch.init({
    appToken: 'your_app_token',
    givenName: 'Cool',
    surname: 'Person',
    email: '[email protected]',
    // For secure mode
    jwt: 'your_jwt',
    userId: 'user_id',
    // Additional properties
    properties: {
        'anything': 'whatever_you_want'    
    },
    customText: {
        headerText: 'How can we help?',
        inputPlaceholder: 'Type a message...',
        sendButtonText: 'Send',
        introductionText: 'We\'re here to talk, so ask us anything!',
        introAppText: 'Message us below or from your favorite app.',
        settingsText: 'You can leave us your email so that we can get back to you this way.',
        settingsReadOnlyText: 'We\'ll get back to you at this email address if we missed you.',
        settingsInputPlaceholder: 'Your email address',
        settingsSaveButtonText: 'Save',
        settingsHeaderText: 'Settings',
        settingsNotificationText: 'In case we\'re slow to respond you can <a href data-ui-settings-link>leave us your email</a>.',
        actionPaymentError: 'An error occurred while processing the card. <br> Please try again or use a different card.',
        actionPaymentCompleted: 'Payment Completed',
        actionPostbackError: 'An error occurred while processing your action. Please try again.',
        messageError: 'An error occured while sending your message. Please try again.',
        invalidFileError: 'Only images are supported. Choose a file with a supported extension (jpg, jpeg, png, gif, or bmp).',
        messageIndicatorTitleSingular: '({count}) New message',
        messageIndicatorTitlePlural: '({count}) New messages',
        connectNotificationText: 'Be notified inside your other apps when you get a reply.',
        notificationSettingsChannelsTitle: 'Other Channels',
        notificationSettingsChannelsDescription: 'You can also talk to us from your favorite app or service.',
        notificationSettingsConnectedAs: 'Connected as {username}',
        notificationSettingsConnected: 'Connected',
        wechatQRCodeError: 'An error occurred while fetching your WeChat QR code. Please try again.',
        messengerChannelDescription: 'Connect your Facebook Messenger account to be notified when you get a reply and carry the conversation on Facebook Messenger.',
        frontendEmailChannelDescription: 'To talk to us using email just send a message to our email address and we\'ll reply shortly:',
        smsChannelDescription: 'Connect your SMS number to be notified when you get a reply and carry the conversation over SMS.',
        smsChannelPendingDescription: 'Check your messages at {number} to confirm your phone number.',
        telegramChannelDescription: 'Connect your Telegram account to be notified when you get a reply and carry the conversation on Telegram',
        wechatChannelDescriptionMobile: 'Connect your WeChat account to be notified when you get a reply and carry the conversation on WeChat. To get started, save this QR code image and upload it in the <a href=\'weixin://dl/scan\'>QR code scanner</a>.',
        wechatChannelDescription: 'Connect your WeChat account to be notified when you get a reply and carry the conversation on WeChat. To get started, scan this QR code using the WeChat app.',
        lineChannelDescription: 'To talk to us using LINE, scan this QR code using the LINE app and send us a message.',
        viberChannelDescriptionMobile: 'Connect your Viber account to be notified when you get a reply and carry the conversation on Viber. To get started, install the Viber app and tap Connect.',
        viberChannelDescription: 'Connect your Viber account to be notified when you get a reply and carry the conversation on Viber. To get started, scan the QR code using the Viber app.',
        smsTooManyRequestsError: 'A connection for that number was requested recently. Please try again in {seconds} seconds.',
        smsBadRequestError: 'We were unable to communicate with this number. Try again or use a different one.',
        smsUnhandledError: 'Something went wrong. Please try again.',
        smsPingChannelError: 'There was an error sending a message to your number.',
        smsLinkCancelled: 'Link to {appUserNumber} was cancelled.',
        smsLinkPending: 'Pending',
        smsStartTexting: 'Start Texting',
        smsChangeNumber: 'Change my number',
        smsSendText: 'Send me a text',
        smsContinue: 'Continue',
        smsCancel: 'Cancel',
        transferError: 'An error occurred when attempting to generate a link for this channel. Please try again.',
        fetchingHistory: 'Retrieving history...',
        fetchHistory: 'Load more',
        clickToRetry: 'Message not delivered. Click to retry.',
        tapToRetry: 'Message not delivered. Tap to retry.',
        locationSendingFailed: 'Could not send location',
        locationServicesDenied: 'This website cannot access your location. Please type your location instead.',
        locationNotSupported: 'This website cannot access your location. Allow access in your settings or type your location instead.',
        locationSecurityRestriction: 'Your browser does not support location services or it’s been disabled. Please type your location instead.'
    }
});


skPromise.then(function() {
    // do something
});

// pass it around...

skPromise.then(function() {
    //do something else
});

open()

Opens the conversation widget (noop when embedded)

Smooch.open();

close()

Closes the conversation widget (noop when embedded)

Smooch.close();

isOpened()

Tells if the widget is currently opened or closed.

Smooch.isOpened();

login(userId [, jwt] [, attributes])

Logs a user in the widget, retrieving the conversation that user already had on other browsers and/or devices. This will destroy and reinitialize the widget with the user's data. Note that you don't need to call this after init, it's already done internally. This returns a promise that resolves when the widget is ready again.

Smooch.login('some-id');

// in case you are using the jwt authentication
Smooch.login('some-id', 'some-jwt');

// in case you want to update user attributes at the same time
Smooch.login('some-id', { email: '[email protected]'});

// in case you want to update user attributes at the same time and use jwt
Smooch.login('some-id', 'some-jwt', { email: '[email protected]'});

logout()

Logs out the current user and reinitialize the widget with an anonymous user.This returns a promise that resolves when the widget is ready again.

Smooch.logout();

destroy()

Destroys the widget and makes it disappear. The widget has to be reinitialized with init to be working again because it also clears up the app token from the widget. It will also unbind all listeners you might have with Smooch.on.

Smooch.destroy();

sendMessage(message)

Sends a message on the user's behalf

Smooch.sendMessage({
    type: 'text',
    text: 'hello'
});

// OR

Smooch.sendMessage('hello');

updateUser(user)

Updates user information

Smooch.updateUser({
    givenName: 'Updated',
    surname: 'Name',
    email: '[email protected]',
    properties: {
      'justGotUpdated': true
    }
});

getUserId()

Returns the userId of the current user.

Smooch.getUserId()

getConversation()

Returns promise that resolves to conversation object, or rejects if none exists

Smooch.getConversation().then(conversation => ...);

track(eventName)

Tracks an event for the current user.

Smooch.track('item-in-cart');

getCore()

Returns an instance of smooch-core to allow access to APIs the Web Messenger doesn't expose. For more information on how to use Smooch-Core, please visit the documentation.

Events

If you want to make sure your events are triggered, try to bind them before calling Smooch.init.

To bind an event, use Smooch.on(<event name>, <handler>);. To unbind events, you can either call Smooch.off(<event name>, handler) to remove one specific handler, call Smooch.off(<event name>) to remove all handlers for an event, or call Smooch.off() to unbind all handlers.

ready

// This event triggers when init completes successfully... Be sure to bind before calling init!
Smooch.on('ready', function(){
    console.log('the init has completed!');
});

Smooch.init(...);

destroy

// This event triggers when the widget is destroyed.
Smooch.on('destroy', function(){
    console.log('the widget is destroyed!');
});

Smooch.destroy();

message:received

// This event triggers when the user receives a message
Smooch.on('message:received', function(message) {
    console.log('the user received a message', message);
});

message:sent

// This event triggers when the user sends a message
Smooch.on('message:sent', function(message) {
    console.log('the user sent a message', message);
});

message

// This event triggers when a message was added to the conversation
Smooch.on('message', function(message) {
    console.log('a message was added to the conversation', message);
});

unreadCount

// This event triggers when the number of unread messages changes
Smooch.on('unreadCount', function(unreadCount) {
    console.log('the number of unread messages was updated', unreadCount);
});

widget:opened

// This event triggers when the widget is opened
Smooch.on('widget:opened', function() {
    console.log('Widget is opened!');
});

widget:closed

// This event triggers when the widget is closed
Smooch.on('widget:closed', function() {
    console.log('Widget is closed!');
});

Embedded mode

As describe above, to activate the embedded mode, you need to pass embedded: true when calling Smooch.init. By doing so, you are disabling the auto-rendering mechanism and you will need to call Smooch.render manually. This method accepts a DOM element which will be used as the container where the widget will be rendered.

The embedded widget will take full width and height of the container. You must give it a height, otherwise, the widget will collapse.

How to contribute

Clone the git repo

git clone https://github.com/smooch/smooch-js

Install Node.js and run the following

npm install

In one console, run npm run dev to start the web server.

Then, go to http://localhost:8282 to test the normal widget or http://localhost:8282/embedded for the embedded one.

Acknowledgements

https://github.com/lipis/flag-icon-css