Skip to content

Commit e823e8f

Browse files
lingling
authored andcommitted
add mini app card docs
1 parent 65a2c73 commit e823e8f

3 files changed

Lines changed: 63 additions & 2 deletions

File tree

docs-src/advanced-kits/imessage/getting-started.mdx.vel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ The client is organized by resource:
159159

160160
| Namespace | What it does |
161161
|---|---|
162-
| `im.messages` | Send text, attachments, multipart messages, replies, reactions, stickers, edits, unsends, list queries, and message events |
162+
| `im.messages` | Send text, attachments, mini app cards, multipart messages, replies, reactions, stickers, edits, unsends, list queries, and message events |
163163
| `im.chats` | Create chats, read chat state, count chats, mark read, set typing, share contact cards, and manage chat backgrounds |
164164
| `im.groups` | Rename groups, manage participants, set group icons, and leave groups |
165165
| `im.attachments` | Upload files, read metadata, and stream downloads |
@@ -172,7 +172,7 @@ The client is organized by resource:
172172

173173
Core path:
174174

175-
1. [Messages](/advanced-kits/imessage/messages) — send text, attachments, multipart messages, reactions, edits, unsends, and subscribe to message events
175+
1. [Messages](/advanced-kits/imessage/messages) — send text, attachments, mini app cards, multipart messages, reactions, edits, unsends, and subscribe to message events
176176
2. [Chats](/advanced-kits/imessage/chats) — create chats, mark read, set typing, and manage chat backgrounds
177177
3. [Events](/advanced-kits/imessage/events) — catch up on durable events after a disconnect
178178
4. [Error Handling](/advanced-kits/imessage/error-handling) — understand error classes, retries, and idempotency keys

docs-src/advanced-kits/imessage/messages.mdx.vel

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Get a `chat.guid` before calling message APIs. `chat.guid` is the server's chat
2222
| Add a message effect | `effect: MessageEffect.*` |
2323
| Format text | `formatting: [...]` |
2424
| Send an attachment | Upload with `im.attachments.upload(...)`, then call `im.messages.sendAttachment(...)` |
25+
| Send a mini app card | `im.messages.sendMiniApp(chat.guid, { url, preview })` |
2526
| Reply to a message | `replyTo` on `sendText(...)`, `sendAttachment(...)`, or `sendMultipart(...)` |
2627
| Send multipart content | `im.messages.sendMultipart(...)` |
2728
| Add or remove a reaction | `im.messages.setReaction(...)` |
@@ -183,6 +184,66 @@ await im.messages.sendAttachment(chat.guid, audio.attachment.guid, {
183184
<img src="/images/advanced-kits/imessage/messages/audio-message.avif" alt="iMessage audio message bubble with play button and waveform" />
184185
</Frame>
185186

187+
## Send Mini App Cards
188+
189+
`sendMiniApp(...)` sends a tappable iMessage card that opens a URL. Use it when you want a custom preview card instead of an automatic link preview.
190+
191+
```ts
192+
const sent = await im.messages.sendMiniApp(chat.guid, {
193+
url: "https://photon.codes",
194+
preview: {
195+
title: "Photon",
196+
subtitle: "photon.codes",
197+
body: "Build messaging agents with advanced iMessage support.",
198+
},
199+
});
200+
201+
console.log(sent.guid);
202+
```
203+
204+
<Frame>
205+
<img src="/images/advanced-kits/imessage/messages/mini-app-card.avif" alt="Mini app card preview showing a Spectrum landing page card" />
206+
</Frame>
207+
208+
The SDK only asks for the destination URL and the preview content shown on the card. The server handles the iMessage app-card details internally.
209+
210+
Only `url` and `preview.title` are required. Most cards should also set `subtitle`, `body`, and `imageJpeg` when that content is available. To include an image, pass JPEG bytes as `preview.imageJpeg`:
211+
212+
```ts
213+
await im.messages.sendMiniApp(chat.guid, {
214+
url: "https://photon.codes",
215+
preview: {
216+
title: "Photon",
217+
subtitle: "photon.codes",
218+
imageJpeg: await readFile("preview.jpg"),
219+
},
220+
});
221+
```
222+
223+
| Field | Required | Meaning |
224+
|---|---|---|
225+
| `url` | Yes | URL opened when the recipient taps the card |
226+
| `preview.title` | Yes | Primary text shown on the card |
227+
| `preview.subtitle` | No | Secondary text |
228+
| `preview.body` | No | Supporting text |
229+
| `preview.imageJpeg` | No | JPEG preview image bytes |
230+
| `preview.caption` | No | Additional small label when the card layout has room |
231+
| `preview.footer` | No | Additional footer label when the card layout has room |
232+
| `preview.detail` | No | Additional detail label when the card layout has room |
233+
| `preview.summary` | No | Fallback summary for surfaces that cannot show the full card |
234+
235+
| Option | Meaning |
236+
|---|---|
237+
| `clientMessageId` | Optional third-argument idempotency key for job retries |
238+
239+
<Warning>
240+
Pass JPEG bytes to `imageJpeg`. If your source image is PNG, WebP, HEIC, or another format, convert it to JPEG before calling `sendMiniApp(...)`.
241+
</Warning>
242+
243+
<Note>
244+
`sendMiniApp(...)` is its own send operation. It does not upload files first, does not take an attachment GUID, and does not use `replyTo` or message effects.
245+
</Note>
246+
186247
## Reply to a Message
187248

188249
To reply to a message, pass the target message GUID as `replyTo`:
69.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)