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

ऑटोमेशन

`automations.list`, `get`, `create`, `update`, `publish`, `pause`, `resume`, `archive`, `duplicate`, `delete`, `send_test`, `stats`, `list_versions`, `restore_version`, `list_starters`, `list_enrollments`, `get_enrollment`, `enroll` और `exit_enrollment`, साथ में `events.send`, `send_batch` और `list_names`।

हर मेथड

automations.py
from openemail import openemail automation = openemail.automations.create({    'name': 'Welcome series',    'starter': 'welcome-series',    'settings': {'timezone': 'Europe/London'},}) saved = openemail.automations.update(automation['id'], {    'definition': {        **automation['definition'],        'trigger': {'kind': 'event', 'eventName': 'trial.started', 'filters': []},    },    'expectedUpdatedAt': automation['updatedAt'],}) blocking = [problem for problem in saved['problems'] if problem['blocking']]if blocking:    raise RuntimeError(blocking[0]['message']) openemail.automations.send_test(saved['id'], {'stepKey': saved['definition']['entry'] or ''})live = openemail.automations.publish(saved['id']) sent = openemail.events.send(    {        'name': 'trial.started',        'email': '[email protected]',        'properties': {'plan': 'starter'},        'createContact': True,    },    idempotency_key='trial:[email protected]',) for enrollment in openemail.automations.iterate_enrollments(live['id'], status='active'):    if enrollment['heldFor']:        print(enrollment['contact']['email'], enrollment['heldFor']) stats = openemail.automations.stats(live['id'])history = openemail.contacts.list_events('[email protected]', name='trial.started') openemail.automations.pause(live['id'])openemail.automations.resume(live['id']) print(sent['enrolled'], stats['totals']['entered'], len(history['items']))

ऑटोमेशन में ड्राफ़्ट की एक definition और चलने वाला published संस्करण रहता है। update ड्राफ़्ट और सेटिंग्स बदलता है, और publish ड्राफ़्ट को अगले संस्करण के रूप में स्थिर करके ऑटोमेशन चालू करता है। problems बताता है कि ड्राफ़्ट को प्रकाशित होने से अभी क्या रोक रहा है, और expectedUpdatedAt उस सेव को 409 version_conflict के साथ मना करता है जो किसी और का सेव मिटा देता।

पढ़ने के लिए automations:read और बदलने के लिए automations:write चाहिए। publish, resume और send_test के लिए emails:send भी चाहिए। events.send और events.send_batch के लिए contacts:write चाहिए, और contacts.list_events के लिए contacts:read। delete पर OAuth एक्सेस टोकन से सत्यापन कोड माँगा जाता है, और API कुंजी से कभी नहीं।

events.send_batch अधिकतम 100 इवेंट लेता है और किसी एक ख़राब इवेंट के लिए कभी एरर raise नहीं करता: जवाब accepted और failed की सूची देता है, हर एक आपकी भेजी सूची में इवेंट के index के साथ।

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

संदर्भ