DTMF control for Pexip Meetings

import xapi from 'xapi';

xapi.Command.UserInterface.Extensions.Panel.Save({ PanelId: 'pexip_panel' }, `<Extensions>
    <Name>Pexip Controls</Name>
      <Name>Pexip DTMF Controls</Name>
	  <Name> In conference control</Name>
          <Name>Change Layout</Name>
          <Name>Lock/Unlock conference</Name>
          <Name>Show/Hide presentation in mix</Name>
          <Name>Mute/Unmute all guests</Name>

//Function to send the DTMF tones during the call.  This receives the DTMF tones from the Event Listenter below.

const sleep = (timeout) => new Promise((resolve) => {
  setTimeout(resolve, timeout);
async function sendDTMF(code, message) {

    try {
        const Level = await xapi.Status.Audio.Volume.get();
        await xapi.Command.Audio.Volume.Set({
            Level: "30",
        console.log("Volume set to 30");

        await sleep(200);
            DTMFString: code,
        console.log("DTMF Values Sent")

        await sleep(750);
        await xapi.Command.Audio.Volume.Set({
        console.log("Volume Set Back to " + Level)

    } catch (error) {

//Event Listener - In this listener we are checking against various Widget ID's to see if they are pressed, and if they are we then send the appropriate DTMF tones to the sendDTMF function listed above.  You can edit each of these to match your WigitID's and/or add/subtract addtional case statements.

xapi.Event.UserInterface.Extensions.Widget.Action.on((event) => {
  if (event.Type !== 'pressed'){
    switch (event.WidgetId) {
      case "changelayout":
        return sendDTMF('*8', 'Change Layout was Pressed');
      case "lock":
        return sendDTMF('*7', 'Conference locked');
      case "presoinmix":
        return sendDTMF('*4', 'Presentation in mix switch pressed');
      case "muteguests":
        return sendDTMF('*5', 'Mute all guests pressed');
1 Like