Simple Modal


I’m getting an error when I try and use the modal option from the interface api

When I use the example provided:

 function openModal(){
   try {
      // app.js
      client.interface.trigger("showModal", {
          title: "Sample Modal",
          template: "modal.html"
  } catch (error) {
      // failure operation

I get:


I use the following on click method to try and call the modal function:

<fw-button onclick="openModal()">Open Modal</fw-button>

Here is the modal.html


    <script src=""></script>
    <script src="../app/scripts/app.js"></script>

    <fw-modal id="open-modal" slier="true">
        <fw-modal-title><span>Example modal</span></fw-modal-title>


Hello @will_bex ,
Welcome to the Freshworks Community!!

Did you initialize the app and set the client object globally. I see that you are using the client.interface API which is returning undefined.

Can you try something like like.

var client;


async function init() {
  client = await app.initialized();'app.activated', registerEvents());

async function registerEvents() {
  const button = document.getElementById('showModal');
  button.addEventListener('click', function(){
    client.interface.trigger("showModal", {
      title: "Sample Modal",
      template: "modal.html"

Hope this helps!!


Thanks Kunal that’s done the trick! :slight_smile: