How to integrate Photo Browser in Messages?

Is there any way to add an array photo when finish upload photo in message? and how to make it work?

My code is working. but, I don’t know is this the right thing to do or not.
for my code I just excuse it every and adding new class.

  var d = new Date();
  var randTime = d.getTime(); // random date class for photo browser
    type: 'sent',
    text: '<a href="#" class="pb'+randTime+'"><img src="' + imgUrl + '" height="100"></a>',
  }, 'append', false);
  var photos = [
  /*=== Standalone Dark ===*/
  var myPhotoBrowserDark = app.photoBrowser.create({
    theme: 'dark'
  $$('.pb'+randTime).on('click', function () {;