cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
123
Views
0
Helpful
0
Replies

Macro - Send info from touchpanel 1- to teams channel.

Help me OBI-WAN you are my only hope.....

Working on a macro that send information from a touch10 panel to a teams channel and running into the error "Unhandled promise rejection: {"code":-32602,"message":"Bad usage: Missing or invalid parameter(s)."}"

Not sure how to deal with this so any input would be helpful!

Here is the program:

import xapi from 'xapi';
xapi.Config.HttpClient.Mode.set('On');
xapi.Event.UserInterface.Extensions.Panel.Clicked.on (panelEvent3);

function panelEvent3(event)
  {
  if (event.PanelId === 'team1_sendbutton')
      {
      showPrompt();
      }
    
// Function to display a prompt with predefined options
function showPrompt()
      {
            xapi.Command.UserInterface.Message.Prompt.Display({
            Title'Assistance needed request',
            Text'What do you need assistance with',
            FeedbackId'assistance-needed',
            'Option.1':'Dialing out to teams meeting',
            'Option.2':'Teams call not connecting',
            'Option.3''Sharing laptop in teams call',
            'Option.4''General help'
           });
      }
     
// Listen for user selection
xapi.Event.UserInterface.Message.Prompt.Response.on(event => {
    if (event.FeedbackId === 'assistance-needed') {
        var userSelection = "";
        switch (event.OptionId) {
            case '1': userSelection = 'Dialing out to teams meeting'break;
            case '2': userSelection = 'Teams call not connecting'break;
            case '3': userSelection = 'Sharing laptop in teams call'break;
            case '4': userSelection = 'General help'break;
            default: userSelection = 'Unknown Option'break;
            }
        var FeedbackId = "";
        console.log("User chose:",userSelection);
                
        const payload = userSelection;
        
        var webhookUrl = ""// Replace with actual Teams webhook URL
  
        sendMessageToTeams(webhookUrl, payload)
        
            }
          });

  async function sendMessageToTeams(url, payload)
  {
    console.log("Payload var:",payload);
    const response = await xapi.Command.HttpClient.Post({
    Url: url,
    Header: ["Content-Type: application/json"],
    BodyJSON.stringify(payload)
        });
          
    console.log("Response:", response);
  }

}
}
 
Thanks for your help with this!!! 
0 Replies 0