Speed dial for Teams Meetings

import xapi from 'xapi';

const speedDial = [
  'teams@pexip.com',
]

xapi.Command.UserInterface.Extensions.Panel.Save({ PanelId: 'speed_dial' }, `
<Extensions>
  <Version>1.0</Version>
  <Panel>
    <PanelId>speed_dial</PanelId>
    <Type>Home</Type>
    <Icon>Handset</Icon>
    <Name>Teams Meeting</Name>
    <ActivityType>Custom</ActivityType>
    <Page>
      <Name>Teams Meeting</Name>

      ${speedDial.map((number) => `
      <Row>
        <Name/>
        <Widget>
          <WidgetId>sd_${number}</WidgetId>
          <Name>${number}</Name>
          <Type>Button</Type>
          <Options>size=4</Options>
        </Widget>
      </Row>
      `).join('')}

      <Options>hideRowNames=1</Options>
    </Page>
  </Panel>
</Extensions>
`);

xapi.Event.UserInterface.Extensions.Widget.Action.on((event) => {
  if (event.Type === 'clicked') {    
    if (event.WidgetId.slice(0, 3) === 'sd_') {
      xapi.Command.Dial({ Number: event.WidgetId.slice(3) });
    }
  }
});

1 Like

If you use different macros for speedDials (like Pexip OTJ-Cloud) on the same Endpoint, please check NOT to use the same WidgetId prefix.

If different Macros listen for the same event then more than one call will be placed at the same tim. You can change these two lines in above macro to avoid the clash:

From: <WidgetId >sd_${number}</WidgetId >
To: <WidgetId >td_${number}</WidgetId >

From: if (event.WidgetId.slice(0, 3) === ‘sd_’) {
To: if (event.WidgetId.slice(0, 3) === ‘td_’) {

2 Likes