Advanced

Customer WebhookPremium

Validate or enrich customer identities before each chat request reaches your agent. Configure a webhook URL on your agent and Meebly will call it on every incoming message, letting you resolve or remap the customerId.

How It Works

  1. 1. A chat request arrives with a customerId.
  2. 2. Meebly sends a POST request to your configured webhook URL.
  3. 3. Your server validates and resolves the customer, returning a customerId.
  4. 4. The chat proceeds with the resolved customerId.

Configuration

Enable the Customer Lookup toggle on your agent in the Meebly dashboard and provide a URL. You can also add custom headers that Meebly will include on every webhook call.

Customer Webhook configuration in the Meebly agent settings

Both the URL and header values support environment variable placeholders so secrets stay out of your config:

text
URL:   https://{{MEEBLY_ENV.MY_API_HOST}}/webhooks/customer
Header value:  Bearer {{MEEBLY_ENV.MY_SECRET_KEY}}

Meebly substitutes {{MEEBLY_ENV.KEY}} tokens with values from your environment variables at runtime. You can also use {{token}} in a header value to inject the signed-in user's auth token.

Incoming Request

Meebly sends a POST with a JSON body and any headers you configured on the agent:

http
POST /webhooks/customer HTTP/1.1
Content-Type: application/json
your-header-key: your-header-value

{
  "customerId": "user_abc123"
}

Response Format

Return a 2xx status with a customerId to allow the request to proceed. This is your opportunity to resolve or remap the customer (e.g. an anonymous ID to an internal one).

json
// 200 OK
{
  "customerId": "internal_user_9876"
}

Example Implementation

A minimal Express.js webhook that validates a header secret, then resolves the customer's internal ID:

javascript
import express from 'express';
const app = express();
app.use(express.json());

app.post('/webhooks/customer', async (req, res) => {
  // Validate the shared secret sent in the configured header
  if (req.headers['x-api-key'] !== process.env.WEBHOOK_SECRET) {
    return res.status(401).json({ message: 'Unauthorized' });
  }

  const { customerId } = req.body;

  const customer = await db.customers.findOne({ externalId: customerId });
  if (!customer) {
    return res.status(403).json({ message: 'Customer not found' });
  }

  // Remap to internal ID so downstream actions use the right identifier
  return res.json({ customerId: customer.internalId });
});
Last updated: March 2026Report an issue