css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
                                        
<html>
<head>
    <title>Qismo Widget Sample</title>
    <link rel="stylesheet" type="text/css" href="https://qiscus-sdk.s3-ap-southeast-1.amazonaws.com/web/v2.5.11/qiscus-sdk.2.5.11.css">
</head>
<body>
<div id="qiscus-widget">
  <div id="qcw-pre-chat" class="qcw-app">
    <div>
      <button class="qcw-trigger-btn qcw-trigger-btn--not-int">
        Chat
      </button>
    </div>
    <div class="qcw-container">
      <div>
        <div class="qcw-header">
          Start a new chat
        </div>
        <form action="" class="qcw-init-chat">
          <p class="qcw-lead">Before we go ahead, please enter your email and your name</p>
          <div class="qcw-form-group">
            <label for="exampleInputEmail1" class="label">Email address</label>
            <input type="email" class="form-control" id="email" aria-describedby="emailHelp" placeholder="Type your active email">
            <small id="emailHelp" class="form-text">We'll never share your email with anyone else.</small>
          </div>
          <div class="qcw-form-group">
            <label for="exampleInputEmail1" class="label">Name</label>
            <input type="text" class="form-control" id="name" aria-describedby="emailHelp" placeholder="Provide a real name too :)">
          </div>
          <button type="submit" class="qcw-btn">Start new chat</button>
        </form>
      </div>
    </div>
  </div>
</div>

<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<script src="https://qiscus-sdk.s3-ap-southeast-1.amazonaws.com/web/v2.5.11/qiscus-sdk.2.5.11.js"></script>
</body>
</html>
            
          
!
            
              $main-color: #4db6ac;
.qcw-header {
  background: linear-gradient(101.53deg, #88FFBB -34.31%, #55D7A9 -5.93%, #23B098 43.57%) !important;
}
.qcw-init-chat {
  padding: 20px;
  
  .qcw-lead { margin-bottom: 35px;}
  
  .qcw-form-group {
    margin-bottom: 20px;
    
    .label,
    .form-control,
    .form-text {
      display: block;
    }
    
    .label {
      font-size: .8rem;
      text-transform: uppercase;
      color: $main-color;
    }
    
    // from materialize    
    .form-control {
      background-color: transparent;
      border: none;
      border-bottom: 2px solid $main-color;
      border-radius: 0;
      outline: none;
      height: 3rem;
      width: 100%;
      font-size: 1rem;
      margin: 0 0 20px 0;
      padding: 0;
      box-shadow: none;
      box-sizing: content-box;
    }
    
    .form-text {
      margin-top: -15px;
      color: #6c757d;
    }
  }
  
  .qcw-btn {
    border: 0;
    border-radius: 15px;
    background: $main-color;
    color: #ecf0f1;
    font-weight: 700;
    padding: 10px 25px;
    cursor: pointer;
    transition: all .12s ease;
    box-shadow: 0 3px 7px rgba(0,0,0,.3);
    text-shadow: 0 -1px 0 rgba(0,0,0,.3);
    outline: none;
  }
}
            
          
!
            
              $(function () {
      // Required vars. Suggested to put all vars in the env vars
      var userID = null;
      var userName = null;
      var ls = JSON.parse(localStorage.getItem('data'));
  
      if (ls !== null && ls.user_id !== null) {
        $("#qcw-init-chat").remove();
        
        userID = ls.user_id
        userName = ls.user_name
        
        initQiscusWidget(userID, userName);
      } else {
        
        $(".qcw-trigger-btn--not-int").click(function() {
          $(".qcw-container").toggleClass("qcw-container--open");
        });
        
        $(".qcw-btn").click(function (event) {
          event.preventDefault();
          
          // please be noted, this example is not using validation, which is not a best practice. So, please make sure to include validation check before submitting any values 
          userID = $("#email").val();
          userName = $("#name").val();
      
          var userData = {
            user_id : userID,
            user_name : userName
          };
          
          localStorage.setItem('data', JSON.stringify(userData));
          userID = userData.user_id;
          userName = userData.user_name;
          
          $("#qcw-init-chat").remove();
          
          initQiscusWidget(userID, userName);
        });
      }
});

function initQiscusWidget(userID, userName) {
  var baseURL = "https://qismo.qiscus.com"
      appId = 'ziv-nqsjtf0zdqf6kfk7s',
      userId = userID;

  // Initiate Qiscus User
  var initUser = $.post(
      baseURL + "/api/v1/qiscus/initiate_chat",
      {
          "app_id": appId,
          "user_id": userId,
          "name": userName
      }
  );

  initUser.done(function (data) {
      var roomId = data.data.room_id;
      var password = data.data.sdk_user.password;
      var sdkEmail = data.data.sdk_user.email;
      QiscusSDK.core.init({
          AppId: appId,
          options: {
              loginSuccessCallback: function (userData) {
                  QiscusSDK.core.UI.chatGroup(roomId);
              }
          }
      });
      // live avatar from https://www.flaticon.com/free-icons/user-avatar_117234
      QiscusSDK.core.setUser(sdkEmail, password, userName, 'https://image.flaticon.com/icons/svg/145/145867.svg');
      QiscusSDK.render();
  });
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console