How to Send WooCommerce Order Details to Help Scout Using Webhooks

How to Send WooCommerce Order Details to Help Scout Using Webhooks

Integrating WooCommerce with Help Scout can be a game-changer for customer support. By automatically sending order details to your Help Scout helpdesk, you can provide more personalized and efficient support to your customers. In this blog post, we’ll walk you through setting up a WooCommerce webhook to send order information to Help Scout.


What Are Webhooks and Why Use Them?

Webhooks allow WooCommerce to send real-time data to other systems whenever specific events occur. By leveraging this functionality, you can ensure that customer order details are instantly available in Help Scout, making your support team better equipped to handle queries.


Prerequisites

Before getting started, ensure you have the following:

  1. WooCommerce Installed: Your WooCommerce store should be fully operational.
  2. Help Scout Account: Make sure you have an active Help Scout account.
  3. Help Scout API Key: This is required to authenticate requests.
  4. Admin Access: You’ll need access to your WordPress dashboard and Help Scout account.

Step 1: Set Up a Webhook in WooCommerce

  1. Log in to your WordPress admin dashboard.
  2. Navigate to WooCommerce > Settings > Advanced > Webhooks.
  3. Click Add Webhook to create a new webhook.
  4. Configure the webhook:
    • Name: Give the webhook a descriptive name, such as “Send Order to Help Scout.”
    • Status: Set to Active.
    • Topic: Choose Order Created to trigger the webhook when a new order is placed.
    • Delivery URL: Enter the URL of your middleware script or API endpoint that will process the webhook and send data to Help Scout.
    • Secret: (Optional) Set a secret key for additional security.
  5. Click Save Webhook.

Step 2: Get Your Help Scout API Key

  1. Log in to your Help Scout account.
  2. Navigate to Manage > API Keys.
  3. Click Generate API Key.
  4. Copy the key and keep it secure—you’ll need it to authenticate requests.

Step 3: Create Middleware or Use a Pre-Built Integration

You’ll need a way to process WooCommerce webhook data and send it to Help Scout. You can either use a no-code platform like Zapier or write a custom script.

Option 1: Use a Pre-Built Integration

If you’re using a tool like Zapier:

  1. Log in to Zapier and create a new Zap.
  2. Select WooCommerce as the trigger app and use the Order Created event.
  3. Authenticate your WooCommerce account.
  4. Add Help Scout as the action app.
  5. Use the Create Conversation action to generate a new Help Scout conversation for each order.
  6. Map WooCommerce order fields (e.g., customer name, email, and order details) to Help Scout fields.

Option 2: Build a Custom Script

If you prefer a custom integration:

  1. Create a script to receive webhook data at the Delivery URL you configured earlier.
  2. Use the Help Scout API to create or update conversations with the order details.

Here’s a sample PHP script:

<?php
// Help Scout API Key
$api_key = 'YOUR_API_KEY';
$api_url = 'https://api.helpscout.net/v2/conversations';

// Function to handle WooCommerce webhook data
function handle_webhook($webhook_data) {
    $order_id = $webhook_data['id'];
    $customer_name = $webhook_data['billing']['first_name'] . ' ' . $webhook_data['billing']['last_name'];
    $customer_email = $webhook_data['billing']['email'];
    $order_total = $webhook_data['total'];
    $order_items = $webhook_data['line_items'];

    // Prepare Help Scout conversation data
    $conversation = [
        'type' => 'email',
        'customer' => [
            'email' => $customer_email
        ],
        'subject' => "Order #$order_id",
        'status' => 'active',
        'mailboxId' => 'YOUR_MAILBOX_ID',
        'threads' => [
            [
                'type' => 'customer',
                'text' => "New order placed:\n\nOrder ID: $order_id\nCustomer: $customer_name\nTotal: $order_total\nItems:\n" . format_items($order_items)
            ]
        ]
    ];

    // Send data to Help Scout
    send_to_helpscout($conversation);
}

// Function to format order items
function format_items($items) {
    $formatted = '';
    foreach ($items as $item) {
        $formatted .= "{$item['name']} (x{$item['quantity']}) - {$item['total']}\n";
    }
    return $formatted;
}

// Function to send data to Help Scout
function send_to_helpscout($data) {
    global $api_url, $api_key;

    $headers = [
        'Authorization: Bearer ' . $api_key,
        'Content-Type: application/json'
    ];

    $ch = curl_init($api_url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    $response = curl_exec($ch);
    curl_close($ch);

    return $response;
}
?>

Step 4: Test the Integration

  1. Place a test order in your WooCommerce store.
  2. Verify that the webhook triggers and sends the order data to your middleware or custom script.
  3. Log in to Help Scout and check for a new conversation with the order details.

Step 5: Monitor and Optimize

  • Regularly check WooCommerce webhook logs to ensure data is being sent.
  • Review Help Scout conversations to confirm accuracy.
  • Adjust the middleware or script as needed to handle additional order details or updates.

Conclusion

By connecting WooCommerce to Help Scout using webhooks, you can automatically provide your support team with the context they need to assist customers effectively. Whether you use a no-code solution or write your own integration, this setup ensures seamless communication between your e-commerce and support systems.

Have questions or tips to share? Let us know in the comments!

Get A No Obligation Quote

Do You Need Help With Your WooCommerce Site?

Click through to the next page and complete the form to get a free no obligation quote to fix any issue you are having with your WooCommerce site.