Awesome Support Documentation

Use Webhook Actions

Many web-hook targets require additional formatting beyond the generic format provided by the add-on.  For these situations the Awesome Support Rules Engine add-on includes a filter that can be used by your developer to format the web-hook payload.  If you don’t know what this means please consult a WordPress developer.

Filter: rules_webhooks_data

Use: Format / re-format web-hook payload

The following example show how to re-format the web-hook payload to conform to the Slack Chat application specifications. (Slack Reference: https://api.slack.com/custom-integrations/incoming-webhooks )

/**
* Send Data To Slack Bot.
*/
add_filter('rules_webhooks_data', 'rules_webhooks_data_callback', 10, 2);

function rules_webhooks_data_callback( $data, $type ) {

     if( !empty($data) && 'webhook' === $type )  {
          $title = $data['title'];
          $creator = $data['creator'];
          $support = $data['support'];
          $rule_id = $data['rule_id'];
          $webhook_url = $data['webhook_url'];
          $data = 'payload={"text": "Ticket '.$title.' created by '.$creator.' and Ticket Assign to '.$support.' And Rule ID is'.$rule_id.' And URL is '.$webhook_url.'"}';
     }

     return $data;
}