> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sendler.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# message.sent

> Triggered when a message is sent to a lead

This event is triggered when a LinkedIn message is successfully sent to a lead, either through campaign automation or via the API.

## When This Event Fires

* Campaign automation sends a follow-up message
* Message is sent via the [Send Message API](https://docs.sendler.ai/api-reference/endpoint/post-send-message.md)
* A message is successfully delivered to the lead's LinkedIn inbox

## Payload

```json theme={null}
{
  "eventId": "evt_1708456789123_abc123def",
  "eventType": "message.sent",
  "timestamp": "2024-02-24T10:30:00.000Z",
  "workspaceId": "ws_abc123xyz",
  "data": {
    "leadId": "lead_abc123",
    "campaignId": "camp_xyz789",
    "linkedinUrl": "https://www.linkedin.com/in/john-doe",
    "senderId": "sender_def456",
    "message": "Hi John! Thank you for connecting. I wanted to reach out about our new product that could help your team increase productivity by 40%. Would you be open to a quick 15-minute call this week?",
    "sequenceStep": 2
  }
}
```

## Payload Fields

| Field | Type | Description |
| - | - | - |
| `eventId` | string | Unique event identifier for idempotency |
| `eventType` | string | Always `message.sent` |
| `timestamp` | string | ISO 8601 timestamp when the message was sent |
| `workspaceId` | string | Your workspace ID |
| `data.leadId` | string | The lead who received the message |
| `data.campaignId` | string | The campaign this lead belongs to |
| `data.linkedinUrl` | string | LinkedIn profile URL of the lead |
| `data.senderId` | string | LinkedIn sender account that sent the message |
| `data.message` | string | Full message content that was sent |
| `data.sequenceStep` | number | Which step in the campaign sequence (if applicable) |

## Use Cases

> **CRM Integration**
>
> Log message activity in your CRM to maintain conversation history

> **Analytics**
>
> Track message delivery and sequence progression

> **Notifications**
>
> Alert team members when outreach is sent

> **Audit Trail**
>
> Build an audit log of all outreach activity

## Example Handler

```javascript theme={null}
app.post('/webhooks/sendpilot', (req, res) => {
  const event = req.body;
  
  if (event.eventType === 'message.sent') {
    const { leadId, campaignId, message, sequenceStep } = event.data;
    
    // Log to your CRM
    await crm.logActivity({
      leadId,
      type: 'linkedin_message_sent',
      content: message,
      metadata: { campaignId, sequenceStep }
    });
    
    console.log(`Message sent to lead ${leadId} (step ${sequenceStep})`);
  }
  
  res.status(200).send('OK');
});
```

> [!NOTE]
>
> The `message` field contains the full message content that was sent to the lead.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.