# Sending Messages

All message types are sent through one function: `sock.sendMessage(jid, content, options)`.

## Text / Reply / Reaction

```ts
await sock.sendMessage('628xxx@s.whatsapp.net', { text: 'Hello!' })
await sock.sendMessage(jid, { text: 'Reply' }, { quoted: message })
await sock.sendMessage(jid, { react: { text: 'fire', key: messageKey } })
await sock.sendMessage(jid, { text: '@user', mentions: ['628xxx@s.whatsapp.net'] })
```

## Media

```ts
await sock.sendMessage(jid, { image: { url: './photo.jpg' }, caption: 'Photo' })
await sock.sendMessage(jid, { video: { url: './video.mp4' }, caption: 'Video' })
await sock.sendMessage(jid, { audio: { url: './audio.ogg' }, mimetype: 'audio/ogg', ptt: true })
await sock.sendMessage(jid, { document: { url: './file.pdf' }, fileName: 'file.pdf' })
```

## Poll / Location / Contact

```ts
await sock.sendMessage(jid, { poll: { name: 'Question?', values: ['A', 'B'], selectableCount: 1 } })
await sock.sendMessage(jid, { location: { degreesLatitude: -6.2, degreesLongitude: 106.8 } })
await sock.sendMessage(jid, { contacts: { displayName: 'Name', contacts: [{ vcard }] } })
```

## Edit / Delete

```ts
await sock.sendMessage(jid, { text: 'Edited', edit: messageKey })
await sock.sendMessage(jid, { delete: messageKey })
```

## Rich Response (Markdown)

```ts
await sock.sendMessage(jid, { text: '# Title\n*Bold* _italic_ `code`\n\n|A|B|\n|---|---|\n|1|2|', rich: true })
```

## Buttons

```ts
await sock.sendMessage(jid, {
  text: 'Choose:',
  buttons: [
    { buttonId: '1', buttonText: { displayText: 'Yes' }, type: 1 },
    { buttonId: '2', buttonText: { displayText: 'No' }, type: 1 },
  ],
})
```

## Template Buttons

```ts
await sock.sendMessage(jid, {
  text: 'Actions:',
  templateButtons: [
    { urlButton: { displayText: 'Open', url: 'https://...' } },
    { quickReplyButton: { displayText: 'OK', id: 'ok' } },
    { callButton: { displayText: 'Call', phoneNumber: '+628xxx' } },
  ],
})
```

## List Select

```ts
await sock.sendMessage(jid, {
  text: 'Select:',
  buttonText: 'View',
  sections: [
    { title: 'Category', rows: [{ id: '1', title: 'Item', description: 'Description' }] },
  ],
})
```

## Album (Multi Image)

```ts
const first = await sock.sendMessage(jid, {
  image: { url: './1.jpg' }, album: { expectedImageCount: 3 },
})
await sock.sendMessage(jid, { image: { url: './2.jpg' }, albumParentKey: first.key })
await sock.sendMessage(jid, { image: { url: './3.jpg' }, albumParentKey: first.key })
```

## Event

```ts
await sock.sendMessage(jid, {
  event: { name: 'Meeting', startDate: new Date(), location: { degreesLatitude: -6.2, degreesLongitude: 106.8 } },
})
```

## View Once / Disappearing

```ts
await sock.sendMessage(jid, { image: { url: './photo.jpg' }, viewOnce: true })
await sock.sendMessage(jid, { text: 'Secret' }, { ephemeralExpiration: 86400 })
```
