version: "0.2.0" minimum_runx: 0.12.0 default_method: send visibility: public category: ops connectors: # The mail connectors a run may choose, the one list of them every skill # that sends or reads mail through message shares. mail: choose: $input.mail.connector from: [mailsim, nitrosend, google/gmail] shared_inputs: mail: type: object description: The mail connector the mailbox is reached through, and where mail arriving from it reaches the loop. additionalProperties: false required: [connector] properties: connector: {type: string, minLength: 1, maxLength: 64} arrives: type: object description: "Where arriving mail reaches the loop: {feed: }, one of the connector's feeds, or {webhook: }, one of the loop's webhooks." additionalProperties: false minProperties: 1 maxProperties: 1 properties: feed: {type: string, minLength: 1, maxLength: 100} webhook: {type: string, minLength: 1, maxLength: 64} methods: send: description: Send one exact email from a mailbox, in its thread when it answers or follows another, at its own gate, once under its key. The connector reads it back by the key. A send the provider queued comes back with no sent_at and the time it's scheduled for. inputs: mail: {} to: {type: string, format: email, maxLength: 320, description: The one recipient.} from_email: {type: string, format: email, maxLength: 320, description: The mailbox it's sent from, which replies come back to.} from_name: {type: string, minLength: 1, maxLength: 255, pattern: "^\\S(.*\\S)?$"} subject: {type: string, minLength: 1, maxLength: 998} body: {type: string, minLength: 1, maxLength: 262144, description: Plain text, exactly as approved.} in_reply_to: type: string maxLength: 998 pattern: "^<[^<>\\s]+>$" description: The Message-ID of the message this one answers or follows, so it goes in that thread. optional: true outreach: type: boolean description: "A first contact, or a follow-up to someone who hasn't written." optional: true unless_inbound_since: type: string format: date-time description: Not sent when the recipient has written since this time. optional: true idempotency_key: {type: string, minLength: 1, maxLength: 255, description: The send's key. The provider keeps one message per key, so a retry never sends twice.} approval_reason: {type: string, minLength: 1, maxLength: 512, description: What the person is shown at the gate.} result_from: [send] examples: - mail: {connector: mailsim} to: priya@northwind.example from_email: sam@acme.example from_name: Sam at Acme subject: Your release notes body: Hi Priya, ... idempotency_key: onboarding-acme:priya@northwind.example:welcome approval_reason: Send this welcome to Priya at Northwind. steps: - id: send operation: mail/message.send idempotency_key: $input.idempotency_key approval: reason: $input.approval_reason type: email result: required: [id, rfc_message_id, to, subject] # sent_at is empty while a provider holds the send to go later, at # scheduled_for; thread_id when the provider gives it at once. optional: [sent_at, scheduled_for, thread_id] equals: to: $input.to inputs: to: $input.to from_email: $input.from_email from_name: $input.from_name subject: $input.subject body: $input.body in_reply_to: $input.in_reply_to outreach: $input.outreach unless_inbound_since: $input.unless_inbound_since receive: description: "What arrived for a mailbox, each message once with its thread and person, and bounces, complaints and away messages as what they are. It takes what a loop was given by its feed or webhook, and reads the inbox unless the connector's feed keeps the cursor: on from `after` for mail posted to a webhook, read with no `arrives`, or whenever `after` is given, and from the start when the feed has a gap. It keeps nothing; the caller keeps the cursor it returns." inputs: mail: {} batch: type: array description: The events of the loop's batch (runx.loop.batch), as runx gave them; only the ones from the mail connector's feed or webhook are read. items: {type: object, additionalProperties: true} optional: true after: type: string minLength: 1 maxLength: 64 description: The cursor the last receive returned, to read the inbox on from. optional: true result_from: [receive] examples: - mail: {connector: mailsim, arrives: {webhook: inbound}} after: "12" steps: - id: receive script: {module: receive.mjs, export: receive} inputs: mail: $input.mail batch: $input.batch after: $input.after # It may call only the inbox's read, so it never sends; a process # connector's read (mailsim's) is one runx can't prove has no effect, # so the step allows effects rather than refusing it. calls: operations: [mail/inbox.read] # Twenty pages of a hundred, then `more` says to read on. max_calls: 40 effects: allow outputs: messages: type: array items: type: object additionalProperties: false required: [id, kind, thread_id, rfc_message_id, from, subject, body, received_at] properties: id: {type: string} kind: {enum: [reply, auto_reply, bounce, complaint]} thread_id: {type: [string, "null"]} rfc_message_id: {type: [string, "null"]} from: {type: string, description: "The person: who wrote, or who a bounce or complaint is about."} subject: {type: [string, "null"]} body: {type: [string, "null"], description: The message as plain, untrusted text.} received_at: {type: string, format: date-time} unreadable: {type: integer, minimum: 0, description: Envelopes that couldn't be read as mail.} gap: {type: boolean, description: The feed couldn't replay from its cursor, so the inbox was read from the start.} cursor: {type: [string, "null"], description: Where the inbox was read to, to give as after next time.} more: {type: boolean, description: The inbox holds more past cursor than this read took.} thread: description: One thread's messages, both ways, oldest first. inputs: mail: {} thread_id: {type: string, minLength: 1, maxLength: 255} result_from: [read] examples: - mail: {connector: mailsim} thread_id: thr_0123456789abcdef steps: - id: read operation: mail/thread.read inputs: thread_id: $input.thread_id