How To Send Notification Email If Gravity Form Webhook Fails

Tagged: 

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #328
    Editorial Staff
    Keymaster

      The following action hook will register if the Gravity Forms webhook is successful i.e. 200 and it will send a corresponding email upon successful completion…

      add_action(
      ‘gform_webhooks_post_request’,
      function ( $response, $feed, $entry, $form ) {
      gf_webhooks()->log_debug( __METHOD__ . json_encode($response) );
      if ( $response[‘response’][‘code’]!=200 ) {
      gf_webhooks()->log_debug( __METHOD__ . ‘(): Sending email for error…’ );
      $error_message = $response[‘body’];
      $to = ’email@emailhere.com’;
      $subject = ‘Webhook failed!’;
      $body = “Webhook for entry #$entry[id] failed. Error: $error_message”;
      wp_mail( $to, $subject, $body );
      gf_webhooks()->log_debug( __METHOD__ . ‘(): Email sent…’ );
      }
      },
      10,
      4
      );

      Reference:
      https://community.gravityforms.com/t/need-help-sending-notification-if-webhook-fails/19983/5

    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.