migma 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +51 -26
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -20,20 +20,64 @@ import { Migma } from 'migma';
20
20
 
21
21
  const migma = new Migma('mgma_sk_live_...');
22
22
 
23
- // Generate an email with AI
24
- const { data, error } = await migma.emails.generateAndWait({
25
- projectId: 'proj_abc123',
23
+ // A project holds your brand info (colors, fonts, logos, tone of voice).
24
+ // Import one from your website, or grab the ID of an existing project
25
+ // from the Migma dashboard.
26
+ const { data: project } = await migma.projects.importAndWait({
27
+ urls: ['https://yourcompany.com'],
28
+ });
29
+
30
+ // Generate an email design with AI — returns the finished HTML directly
31
+ const { data: email } = await migma.emails.generateAndWait({
32
+ projectId: project.projectId,
26
33
  prompt: 'Create a welcome email for new subscribers',
27
34
  });
28
35
 
29
- if (data?.status === 'completed') {
30
- console.log(data.result.subject);
31
- console.log(data.result.html);
36
+ if (email?.status === 'completed') {
37
+ console.log('Subject:', email.result.subject);
38
+ console.log('HTML:', email.result.html); // production-ready HTML
32
39
  }
33
40
  ```
34
41
 
42
+ > **Prefer async?** Use `migma.emails.generate()` to kick off generation without waiting,
43
+ > then set up a [webhook](https://docs.migma.ai/webhooks) to get notified when the design is ready
44
+ > via the `email.generation.completed` event — no polling needed.
45
+
35
46
  Get your API key from the [Migma Dashboard](https://migma.ai) under **Settings > API Integration > API Keys**.
36
47
 
48
+ ### Quick Start with OpenClaw
49
+
50
+ [OpenClaw](https://openclaw.ai/) (formerly ClawdBot) is an open-source AI agent for WhatsApp, Telegram, and Discord. Pair it with Migma to generate and send professional emails from a single chat command.
51
+
52
+ ```typescript
53
+ import { Migma } from 'migma';
54
+
55
+ const migma = new Migma(process.env.MIGMA_API_KEY);
56
+
57
+ // 1. Set up an instant sending domain (no DNS needed)
58
+ await migma.domains.createManaged({ prefix: 'yourcompany' });
59
+
60
+ // 2. Generate an on-brand email with AI
61
+ const { data: email } = await migma.emails.generateAndWait({
62
+ projectId: process.env.MIGMA_PROJECT_ID, // your brand project
63
+ prompt: 'Create a summer sale email with 30% off everything',
64
+ });
65
+
66
+ // 3. Send it
67
+ await migma.sending.send({
68
+ recipientType: 'email',
69
+ recipientEmail: 'sarah@example.com',
70
+ from: 'hello@yourcompany.migma.email',
71
+ fromName: 'Your Company',
72
+ subject: email.result.subject,
73
+ template: email.result.html,
74
+ providerType: 'migma',
75
+ projectId: process.env.MIGMA_PROJECT_ID,
76
+ });
77
+ ```
78
+
79
+ [Full OpenClaw tutorial](https://docs.migma.ai/tutorials/send-emails-from-openclaw)
80
+
37
81
  ## Documentation
38
82
 
39
83
  | Resource | Link |
@@ -393,26 +437,7 @@ await migma.previews.createAndWait(params, options);
393
437
 
394
438
  ### Send emails from WhatsApp/Telegram via OpenClaw
395
439
 
396
- [OpenClaw](https://openclaw.ai/) is an open-source AI agent for messaging apps. Pair it with Migma to send professional emails from a single chat command — no ESP dashboard needed.
397
-
398
- ```typescript
399
- // Set up a managed domain (instant, no DNS)
400
- await migma.domains.createManaged({ prefix: 'yourcompany' });
401
-
402
- // Send from your OpenClaw bot
403
- await migma.sending.send({
404
- recipientType: 'email',
405
- recipientEmail: 'sarah@example.com',
406
- from: 'hello@yourcompany.migma.email',
407
- fromName: 'Your Company',
408
- subject: 'Hello from OpenClaw',
409
- template: '<h1>Hi!</h1><p>Sent via OpenClaw + Migma.</p>',
410
- providerType: 'migma',
411
- projectId: 'proj_abc123',
412
- });
413
- ```
414
-
415
- [OpenClaw Guide](https://docs.migma.ai/integrations/openclaw)
440
+ See [Quick Start with OpenClaw](#quick-start-with-openclaw) above, or read the [full tutorial](https://docs.migma.ai/tutorials/send-emails-from-openclaw).
416
441
 
417
442
  ### Generate + validate + send in one pipeline
418
443
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "migma",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Official Node.js SDK for the Migma email platform API",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",