Menu

Error: The callback '\WebhookHelper::GenerateTTOAlert' is not valid

daniel
5 days ago
5 days ago
  • daniel

    daniel - 5 days ago

    Dear friends, could you please advise on how to handle this? I added a webhook using the Prepare payload callback \WebhookHelper::GenerateTTOAlert, but an error occurred:

    Error: The callback '\WebhookHelper::GenerateTTOAlert' is not valid.

     
  • jf-cbd

    jf-cbd - 5 days ago

    Hello, can you send the code of GenerateTTOAlert ?
    This error means you can't call it, it can be for several reasons, wrong visibility, wrong name, etc

     
    • daniel

      daniel - 5 days ago

      Thank you for your reply.I have created two files in the itop/extensions/webhook_helper directory: one is main.php, and the other is webhookhelper.class.inc.php.

      1.main.php

      'Webhook Helper', 'description' => 'Generates dynamic payloads for enterprise WeChat webhooks', 'version' => '1.0.0', 'author' => 'Admin', 'license' => 'MIT', ); } public function ListAPIClasses() { return array( 'WebhookHelper' => 'webhookhelper.class.inc.php', ); } } ?>
      1. webhookhelper.class.inc.php
      Get('ref'); $title = $ticket->Get('title'); $status = $ticket->Get('status'); return array( 'msgtype' => 'text', 'text' => array( 'content' => "[TTO Alert]\nA ticket (ID: {$ref}) is awaiting assignment for response. Please handle it promptly!\nTitle: {$title}\nStatus: {$status}" ) ); } } ?>
       
  • jf-cbd

    jf-cbd - 5 days ago

    Thank you for the details. Where is the GenerateTTOAlert function in the webhookhelper class ?

     
    • daniel

      daniel - 5 days ago
      <?php
      /**
       * Enterprise WeChat Webhook Helper Class
       */
      class WebhookHelper {
          /**
           * Generate payload for TTO timeout alert
           * @param DBObject $oObject The object that triggered the action
           * @param array $aContextArgs Context parameters
           * @param EventNotification $oLog Log object
           * @param ActionWebhook $oAction Webhook action
           * @return array JSON payload with replaced variables
           */
          public static function GenerateTTOAlert(DBObject $oObject, array $aContextArgs, EventNotification $oLog, ActionWebhook $oAction) {
              $ticket = $oObject;
              $ref = $ticket->Get('ref');
              $title = $ticket->Get('title');
              $status = $ticket->Get('status');
      
              return array(
                  'msgtype' => 'text',
                  'text' => array(
                      'content' => "[TTO Alert]\nA ticket (ID: {$ref}) is awaiting assignment for response. Please handle it promptly!\nTitle: {$title}\nStatus: {$status}"
                  )
              );
          }
      }
      ?>
      
       

Log in to post a comment.