दस्तावेज़ पर जाएँ
PHP

ऑटोमेशन

`automations->list`, `get`, `create`, `update`, `publish`, `pause`, `resume`, `archive`, `duplicate`, `delete`, `sendTest`, `stats`, `listVersions`, `restoreVersion`, `listStarters`, `listEnrollments`, `getEnrollment`, `enroll` और `exitEnrollment`, साथ में `events->send`, `sendBatch` और `listNames`।

हर मेथड

automations.php
use OpenEmail\Constants\AutomationEnrollmentStatuses;use OpenEmail\Constants\AutomationTriggerKinds; $automation = $client->automations->create([    'name' => 'Welcome series',    'starter' => 'welcome-series',    'settings' => ['timezone' => 'Europe/London'],]); $definition = $automation['definition'];$definition['trigger'] = ['kind' => AutomationTriggerKinds::EVENT, 'eventName' => 'trial.started', 'filters' => []]; $saved = $client->automations->update($automation['id'], [    'definition' => $definition,    'expectedUpdatedAt' => $automation['updatedAt'],]); foreach ($saved['problems'] as $problem) {    if ($problem['blocking']) {        throw new \RuntimeException($problem['message']);    }} $client->automations->sendTest($saved['id'], ['stepKey' => $saved['definition']['entry'] ?? '']);$live = $client->automations->publish($saved['id']); $sent = $client->events->send([    'name' => 'trial.started',    'email' => '[email protected]',    'properties' => ['plan' => 'starter'],    'createContact' => true,], idempotencyKey: 'trial:[email protected]'); foreach ($client->automations->iterateEnrollments($live['id'], status: AutomationEnrollmentStatuses::ACTIVE) as $enrollment) {    if ($enrollment['heldFor'] !== null) {        echo $enrollment['contact']['email'], ' ', $enrollment['heldFor'], PHP_EOL;    }} $stats = $client->automations->stats($live['id']);$history = $client->contacts->listEvents('[email protected]', name: 'trial.started'); $client->automations->pause($live['id']);$client->automations->resume($live['id']); echo count($sent['enrolled']), ' ', $stats['totals']['entered'], ' ', count($history->items), PHP_EOL;

ऑटोमेशन में ड्राफ़्ट की एक 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 के साथ।

संपर्क का attributes उसके कस्टम फ़ील्ड रखता है, और ऑटोमेशन किसी एक को attributes.<key> के रूप में पढ़ता है।