With the help of the following steps, you will be able to do the integration of Mailster with Groupboss:

  • Before you do the integration, there are some additional steps you need to follow:
  • Go to your WordPress (WP) dashboard. Then from the left side toolbar go to; Plugins >> Add New Plugin
WordPress Dahsboard
  • Now find ‘WPCode – Insert Headers and Footers + Custom Code Snippets – WordPress Code Manager’, or ‘Code Snippets’ and activate one of the plugins or both.
MailPoet Integration With Groupboss
  • Once the activation of the plugins is done– go to Snippets >> Add New.
Snippets Add New
  • Then a new interface will be generated.
MailPoet Integration With Groupboss
  • Now copy and paste the below code (Code Preview) in the box. Scroll down and click the option ‘Run snippet everywhere’ below the code snippet box. Then click Save Changes and Activate. A new notification will come at the top with Snippet activated and created.
Code Preview
Code Preview

// Function to retrieve Mailster subscribers (GET request)
function prefix_get_mailster_subscribers(WP_REST_Request $request) {
// Get parameters from the request
$limit = $request->get_param('limit') ?: 10; // Default to 10
$lists = $request->get_param('lists');
$fields = $request->get_param('fields') ?: 'all';
$meta = $request->get_param('meta') ?: '';

// Prepare the arguments for the Mailster query
$args = array(
'limit' => (int)$limit,
'fields' => $fields,
'meta' => array_filter(explode(',', $meta)), // Clean and split meta into an array
);

// Add lists to the arguments if provided
if ($lists) {
$args['lists'] = array_filter(explode(',', $lists));
}

try {
// Query Mailster subscribers
$subscribers = mailster('subscribers')->query($args);

// Return the response
return new WP_REST_Response($subscribers, 200);
} catch (Exception $e) {
// Handle errors gracefully
return new WP_Error('mailster_error', $e->getMessage(), array('status' => 400));
}
}

// Function to check if Mailster is active (ping request)
function prefix_mailster_ping() {
return new WP_REST_Response(array(
'message' => 'Mailster API is working.',
'status' => 'success',
), 200);
}

// Function to add a single subscriber to a list
function prefix_add_subscriber_to_list(WP_REST_Request $request) {
$payload = $request->get_json_params();
// Validate input
if (empty($payload['email']) || !is_email($payload['email'])) {
return new WP_Error('invalid_input', 'Invalid or missing email.', array('status' => 400));
}

if (empty($payload['list_id']) || !is_numeric($payload['list_id'])) {
return new WP_Error('invalid_list_id', 'Invalid or missing list ID.', array('status' => 400));
}

try {
// Add the subscriber
$subscriber_id = mailster('subscribers')->add(array(
'firstname' => $payload['firstname'] ?? '',
'lastname' => $payload['lastname'] ?? '',
'email' => $payload['email'],
'status' => $payload['status'] ?? 1 // Default to subscribed (1)
), $overwrite = true); // Overwrite existing subscribers if they already exist

// Check for errors during the add process
if (is_wp_error($subscriber_id)) {
return new WP_Error('subscriber_add_error', 'Failed to add subscriber: ' . $subscriber_id->get_error_message(), array('status' => 400));
}

// Assign the subscriber to the list
$success = mailster('subscribers')->assign_lists($subscriber_id, $payload['list_id']);

if (!$success) {
return new WP_Error('assign_list_error', 'Failed to assign subscriber to the list.', array('status' => 400));
}

// Return a success message
return new WP_REST_Response(array(
'status' => 'success',
'message' => 'Subscriber added and assigned to list successfully.',
), 200);

} catch (Exception $e) {
return new WP_Error('mailster_error', 'Error adding subscriber: ' . $e->getMessage(), array('status' => 400));
}
}

// Function to check if a list exists by ID
function prefix_check_list(WP_REST_Request $request) {
$payload = $request->get_json_params();

// Validate input
if (empty($payload['id']) || !is_numeric($payload['id'])) {
return new WP_Error('invalid_list_id', 'Invalid or missing list ID.', array('status' => 400));
}

$list_id = (int) $payload['id'];

// Check if the list exists
$list = mailster('lists')->get($list_id);

if (!$list) {
return new WP_REST_Response(array(
'success' => false,
'message' => 'List not found.',
), 400);
}

// If found, return success
return new WP_REST_Response(array(
'success' => true,
'message' => 'List found.',
'list' => $list,
), 200);
}


// Register REST API routes for Mailster
function prefix_register_mailster_routes() {
// Check if Mailster is active
if (function_exists('mailster')) {
// Route to retrieve Mailster subscribers
register_rest_route('mailster/v1', '/subscribers', array(
'methods' => 'GET',
'callback' => 'prefix_get_mailster_subscribers',
'permission_callback' => '__return_true', // Adjust this for better security
));
// Route for adding a single subscriber
register_rest_route('mailster/v1', '/add-subscriber', array(
'methods' => 'POST',
'callback' => 'prefix_add_subscriber_to_list',
'permission_callback' => '__return_true',
));

// Route for pinging Mailster API
register_rest_route('mailster/v1', '/ping', array(
'methods' => 'GET',
'callback' => 'prefix_mailster_ping',
'permission_callback' => '__return_true', // Adjust this for better security
));

register_rest_route('mailster/v1', '/check-list', array(
'methods' => 'POST',
'callback' => 'prefix_check_list',
'permission_callback' => '__return_true', // Adjust this for better security
));
}
}
add_action('rest_api_init', 'prefix_register_mailster_routes');
        
  • Then go to this link: https:// [Your Domain Address in WordPress] /?rest_route=/mailster/v1/ping and if your snippet is activated and working fine then a message will show stating MailPoet API is working and status Success. If this message comes then you can start following the next steps.
MailPoet Integration With Groupboss

Now comes the main part of the integration. With the help of the following steps, you will be able to do the integration of Mailster with Groupboss:

  • First, go to the Chrome extension store. Then add the Groupboss extension, and click on the Groupboss extension icon.
  • Furthermore, click on Configure My Group and select a Facebook group and tap on the settings icon beside that group.
  • Then go to Autoresponder, hit the drop-down icon, and select Mailster. Now click Add.
  • Then provide your site URL and the List ID.

Eventually, your integration will be done and you'll find the Mailster integration under the list of currently activated.

  • Now go to your Facebook group’s homepage, find member request. Now accept a friend request who has answered all the questions by tapping Approve by Groupboss.
  • Once you have approved, go to the Mailster >> Subscribers and find the accepted member’s data.

This is the overall step-by-step summary of Mailster integration with Groupboss to generate your lead automatically and ensure a sharp edge over your competitors.