ऑटोमेशन
`automations.list`, `get`, `create`, `update`, `publish`, `pause`, `resume`, `archive`, `duplicate`, `delete`, `sendTest`, `stats`, `listVersions`, `restoreVersion`, `listStarters`, `listEnrollments`, `getEnrollment`, `enroll` और `exitEnrollment`, साथ में `events.send`, `sendBatch` और `listNames`।
हर मेथड
const automation = await openemail.automations.create({ name: 'Welcome series', starter: 'welcome-series', settings: { timezone: 'Europe/London' },}) const saved = await openemail.automations.update(automation.id, { definition: { ...automation.definition, trigger: { kind: 'event', eventName: 'trial.started', filters: [] } }, expectedUpdatedAt: automation.updatedAt,}) if (saved.problems.some((problem) => problem.blocking)) throw new Error(saved.problems[0]?.message) await openemail.automations.sendTest(saved.id, { stepKey: saved.definition.entry ?? '' })const live = await openemail.automations.publish(saved.id) const sent = await openemail.events.send( { name: 'trial.started', email: '[email protected]', properties: { plan: 'starter' }, createContact: true }, { idempotencyKey: 'trial:[email protected]' },) for await (const enrollment of openemail.automations.iterateEnrollments(live.id, { status: 'active' })) { if (enrollment.heldFor) console.log(enrollment.contact.email, enrollment.heldFor)} const stats = await openemail.automations.stats(live.id)const history = await openemail.contacts.listEvents('[email protected]', { name: 'trial.started' }) await openemail.automations.pause(live.id)await openemail.automations.resume(live.id) console.log(sent.enrolled, stats.totals.entered, history.items.length)ऑटोमेशन में ड्राफ़्ट की एक definition और चलने वाला published संस्करण रहता है। update ड्राफ़्ट और सेटिंग्स बदलता है, और publish ड्राफ़्ट को अगले संस्करण के रूप में स्थिर करके ऑटोमेशन चालू करता है। problems बताता है कि ड्राफ़्ट को प्रकाशित होने से अभी क्या रोक रहा है, और expectedUpdatedAt उस सेव को 409 version_conflict के साथ मना करता है जो किसी और का सेव मिटा देता।
पढ़ने के लिए automations:read और बदलने के लिए automations:write चाहिए। publish, resume और sendTest के लिए emails:send भी चाहिए। events.send और events.sendBatch के लिए contacts:write चाहिए, और contacts.listEvents के लिए contacts:read। delete पर OAuth एक्सेस टोकन से सत्यापन कोड माँगा जाता है, और API कुंजी से कभी नहीं।
events.sendBatch अधिकतम 100 इवेंट लेता है और किसी एक ख़राब इवेंट के लिए कभी एरर नहीं फेंकता: जवाब accepted और failed की सूची देता है, हर एक आपके भेजे ऐरे में इवेंट के index के साथ।