# Vercel Chat SDK iMessage Adapter

> Build an iMessage, RCS, and SMS chatbot with Vercel's Chat SDK using Blooio's `chat-adapter-blooio` community adapter.

Source: https://blooio.com/integrations/chat-sdk

## Summary

The `chat-adapter-blooio` community adapter connects a Vercel Chat SDK bot to Blooio's hosted messaging gateway. Build a bot once, then send and receive messages over iMessage, RCS, and SMS through the standard Chat SDK interface.

The adapter supports native iMessage-oriented interactions including tapbacks, typing indicators, read receipts, media attachments, contact capability checks, and signed webhook verification.

## Install

```bash
pnpm add chat-adapter-blooio
```

Alternative package managers:

```bash
npm i chat-adapter-blooio
yarn add chat-adapter-blooio
```

## Capabilities

- Send and receive iMessage, RCS, and SMS through one adapter
- Add and remove the six iMessage tapback reactions
- Send typing indicators in one-to-one and group conversations
- Mark conversations as read
- Send media attachments with an optional message
- Check whether a contact supports iMessage, SMS, or both before sending
- Access the underlying Blooio API client for requests such as contact and group management
- Verify inbound webhook signatures with HMAC-SHA256

## Quickstart

### Create a Chat SDK bot

```typescript
import { Chat } from "chat";
import { createBlooioAdapter } from "chat-adapter-blooio";

export const chat = new Chat({
  userName: "my-bot",
  adapters: {
    blooio: createBlooioAdapter(),
  },
});
```

### Add a Blooio webhook route

```typescript
import { chat } from "@/lib/bot";

export async function POST(request: Request) {
  await chat.initialize();
  return chat.webhooks.blooio(request);
}
```

Configure Blooio to send webhooks to this route.

### Send a message

```typescript
await chat.send("blooio", threadId, "Hello from the bot!");
```

## Environment Variables

| Variable | Required | Purpose |
|---|---:|---|
| `BLOOIO_API_KEY` | Yes | Blooio API key used as a Bearer token |
| `BLOOIO_FROM_NUMBER` | No | Default E.164 sending number for multi-number accounts |
| `BLOOIO_WEBHOOK_SECRET` | No | Enables HMAC-SHA256 webhook verification |

## Common Recipes

### Add or remove a tapback

```typescript
import type { BlooioAdapter } from "chat-adapter-blooio";

const adapter = chat.getAdapter("blooio") as BlooioAdapter;

await adapter.addReaction(threadId, messageId, "love");
await adapter.removeReaction(threadId, messageId, "love");
```

### Send an attachment

```typescript
const adapter = chat.getAdapter("blooio") as BlooioAdapter;

await adapter.sendMediaMessage(
  threadId,
  "https://example.com/photo.jpg",
  "Check this out"
);
```

### Check contact capabilities

```typescript
const result = await adapter.checkCapabilities("+15551234567");
```

The result identifies whether the contact supports iMessage, SMS, or both.

### Use the Blooio API client directly

```typescript
const client = adapter.getClient();

await client.request("GET", "/contacts", undefined, { limit: "50" });

await client.request("POST", "/groups", {
  name: "Team",
  members: ["+15551234567"],
});
```

## Signed Webhooks

When a webhook secret is configured, the adapter verifies the `X-Blooio-Signature` header and rejects stale timestamps.

```text
X-Blooio-Signature: t=<unix_ts>,v1=<hmac_sha256_hex>
```

Example adapter configuration:

```typescript
createBlooioAdapter({
  webhookSecret: "whsec_...",
  timestampToleranceSec: 600,
  allowedProtocols: ["imessage"],
});
```

The `allowedProtocols` filter is optional.

### Webhook Events

- `message.received` — incoming iMessage, RCS, or SMS
- `message.sent`
- `message.delivered`
- `message.failed`
- `message.read`
- `message.reaction` — a tapback on a message

## Limitations

iMessage message editing and unsending are not supported through this API integration.

- `editMessage` throws an error.
- `deleteMessage` is a no-op.

## Links

- HTML page: https://blooio.com/integrations/chat-sdk
- Adapter documentation: https://chat-sdk.dev/adapters/community/blooio
- REST API integration: https://blooio.com/integrations/api.md
- MCP server integration: https://blooio.com/integrations/mcp.md
- Integrations overview: https://blooio.com/integrations.md
- iMessage bot guide: https://blooio.com/guides/imessage-bot.md
- Pricing: https://blooio.com/pricing.md
- Site index: https://blooio.com/llms.txt
