Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>
  <head>
    <title>Qiscus SDK Sample</title>
    <script
  src="http://code.jquery.com/jquery-3.3.1.min.js"
  integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  crossorigin="anonymous"></script>
    <link rel="stylesheet" type="text/css" href="https://qiscus-sdk.s3-ap-southeast-1.amazonaws.com/web/v2.8.3/qiscus-sdk.2.8.3.css">
  </head>
  <body>
    <h3>Auto trigger say hi!</h3>
    <div id="qiscus-widget"></div>
    <script src="https://qiscus-sdk.s3-ap-southeast-1.amazonaws.com/web/v2.8.3/qiscus-sdk.2.8.3.js"></script>
  </body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                // generate random user data in localstorage
var e = null, t = null, r = null, n = null,first_chat = null, u = JSON.parse(localStorage.getItem("data"));
if (u !== null) {
  (e = u.user_id), (t = u.user_key), (r = u.user_name), (n = u.avatar), (first_chat = u.first_chat);
  console.log("not first time " + u.first_chat);
}
else {
  for (
    var s = null,
      a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
      c = 0;
    c < 5;
    c++
  )
    s += a.charAt(Math.floor(Math.random() * a.length));
  var o = Date.now(),
    i = {
      user_id: s + "@qiscus.co",
      user_key: o,
      user_name: "Qiscus Guest - " + o,
      avatar:
        "https://d1edrlpyc25xu0.cloudfront.net/kiwari-prod/image/upload/wMWsDZP6ta/1516689726-ic_qiscus_client.png",
      first_chat: true
    };
  localStorage.setItem("data", JSON.stringify(i)),
    (e = i.user_id),
    (t = i.user_key),
    (r = i.user_name),
    (n = i.avatar),
    (first_chat = i.first_chat);
  console.log("first time " + i.first_chat);
}


QiscusSDK.core.init({
  AppId: "cobacoba-mm29xdr4se8f",
  options: {
    avatar: !0,
    loginSuccessCallback: function() {
      // Do something after successfully login
      // Chat with available user, need to be register first
      QiscusSDK.core.UI.chatTarget("qo@qiscus.com");
    },
    chatRoomCreatedCallback: function (room) {
      // if this is for the first time user is having chat, than send "hi" to SDK
      // as first trigger for bot
      console.log(first_chat);
      if (first_chat) {
        var activeRoomId = QiscusSDK.core.selected.id;
        var today = new Date();
        var uniqueId = today.getTime();
        var messageText = 'Hi' // you can use any text to trigger bot to start a conversation
        
        // send comment to SDK
        QiscusSDK.core.sendComment(
            activeRoomId,
            messageText,
            uniqueId
        );
        
        // update first_chat value
        i['first_chat'] = false;
        localStorage.setItem("data", JSON.stringify(i))
      }
    }
  }
});
QiscusSDK.core.setUser(e, t, r, n);
QiscusSDK.render();

              
            
!
999px

Console