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

blip-chat-extension

v1.0.4

Published

* `npm install` * `npm start` * Project will be running on `http://localhost:3002`

Downloads

575

Readme

Running

  • npm install
  • npm start
  • Project will be running on http://localhost:3002

WebView

Control BLiP Chat's webview from your web page. You may need to have some control over BLiP Chat's webview once you have added it to your web page. This script extension allows you to that.

Usage

NPM

Simply install the blip-chat-extension package from the npm registry.

$ npm install blip-chat-extension

Now you just have to import the package and use it:

var blipCards = require("blip-chat-extension");
  (function () {
    window.onload = function () {
      var WebView = new BlipChatExtension()
    }
  })();

Script Import

To import the script just copy and paste the following code:

<script src="https://unpkg.com/[email protected]" type="text/javascript">
</script>
<script>
    (function () {
        window.onload = function () {
          var WebView = new BlipChatExtension()
        }
    })();
</script>

You should create an instance of BlipChatExtension and operate on it.

Closing the WebView

You may need to close BLiP Chat's webview after an event or transaction has finished. To close the webview use the method closeWebView from the instanced object.

var WebView = new BlipChatExtension()
WebView.closeWebView()

Sending a message to the chatbot

If the chatbot's conversation state has stopped and you need to update that state (after some interaction with your web page, for example) use the method sendMessage to send a message to the chatbot.

var WebView = new BlipChatExtension()
// Sending a simple text message
WebView.sendMessage("My simple text message")
// Sending a media link message 
WebView.sendMessage({
  "type": "application/vnd.lime.media-link+json",
  "content": {
    "title": "My image message",
    "text": "Here is a cat image for you!",
    "type": "image/jpeg",
    "uri":
      "http://2.bp.blogspot.com/-pATX0YgNSFs/VP-82AQKcuI/AAAAAAAALSU/Vet9e7Qsjjw/s1600/Cat-hd-wallpapers.jpg",
    "aspectRatio": "1:1",
    "size": 227791,
    "previewUri":
      "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS8qkelB28RstsNxLi7gbrwCLsBVmobPjb5IrwKJSuqSnGX4IzX",
    "previewType": "image/jpeg"
  }
})

You can send any document supported on blip. To see more go to BLiP Help Center.

If you need to send a complex message, you can send an object with the properties payload and preview. They are used to specify what is sent to chatbot and what is shown to user respectively.

Examples

Should you need to send your location to the chatbot but only a simple text like I'm here is to be shown to the user, you can do it as follows:

var WebView = new BlipChatExtension()
// Sending Location card to chatbot and showing a text message to user
WebView.sendMessage({
  "payload": {
    "type": "application/vnd.lime.location+json",
    "content": {
      "latitude": -19.918899,
      "longitude": -43.959275,
      "altitude": 853,
      "text": "Take's place"
    }
  },
  "preview": {
    "type": "text/plain",
    "content": "Im here"
  }
})

Or maybe you have some content to be trafficked that the user should not see. For that you should send the object keeping the payload but omitting the preview property.

var WebView = new BlipChatExtension()
// Sending a message to the chatbot that the user will not see it's content
WebView.sendMessage({
  "payload": {
    "type": "text/plain",
    "content": "Hidden content"
  }
})

Override Webview's Close Method

With the method overrideOnClose you can, for example, guarantee that a form is submitted before the user closes the webview. The function to be executed when the user tries to close the webview is passed as a parameter to the method:

var WebView = new BlipChatExtension()
WebView.overrideOnClose(function () {
  alert('Please complete the form before leaving')
  return false // Prevent webview from closing
})

The overrideOnClose method has a return that determines whether the webview should be closed or not . By returning true the webview's closing method will proceed normally and by returning false it will be blocked.

var WebView = new BlipChatExtension()
WebView.overrideOnClose(function () {
  WebView.sendMessage('Webview will close')
  return true // Webview will close
})

Methods

| Methods | Description | Parameters | | ----------------- | ----------------------------------------- | -------------------------------------- | | closeWebView | Close the webview | None | | sendMessage | Send a message to bot in name of the user | string or { preview: {}, payload: {} } | | overrideOnClose | Override webview's default close function | function |