Following our introduction to facets, let me tell you some more about the upcoming email facet. The idea is that every object and record will have its own canonical email address to which emails can be sent. When sending an email to an object or a record, a specific action will be executed on the object or the record, based on the email’s subject and body. This will essentially give objects and records an email persona, capable of automating many different actions.
Canonical Object Email Address
The local part of the canonical email address for an object will be the object’s identifier (namespace included). Alternatively, a different local part can be assigned to the object by populating its stc_local_part field. For example, the User object will have the following canonical email address:
stc_user@yourdomain.com
And if you were to set stc_local_part to “user” for it, the following would also become available:
user@yourdomain.com
Canonical Record Email Address
The local part of the canonical email address for a record will be the identifier of the record’s object, followed by a dot, then followed by the record’s UUID. Alternatively, the object’s custom Local Part can be used, and the object’s identifier can be omitted for brevity purposes (once we support high-performance reverse lookup with elasticsearch). As a result, the record for my user (Ismael Ghalimi) will have the following canonical email addresses:
stc_user.31415926-9df7-4aa6-994f-600567b0a37a@stoic.com
user.31415926-9df7-4aa6-994f-600567b0a37a@stoic.com
31415926-9df7-4aa6-994f-600567b0a37a@stoic.com
From there, a set of email actions are made automatically available, some implicit, other explicit. Implicit email actions are executed for all inbound emails, irrespectively of their subjects. Explicit email actions are executed in response to inbound emails that have a specific subject. Some explicit email actions also require additional parameters, which are set in the email’s body, following a very simple syntax.
Attach Files (implicit)
All files attached to an email sent to a record are added to the record’s stc_files field.
Store as Comment (Implicit)
The original email sent to a record is added as a comment to the record.
Create (Explicit)
To create a new record of an object, simply send an email to the object with the “create” subject (case insensitive), and set the record’s field values with one line per field, the field’s identifier (namespace optional), a colon sign (:), and the field’s value. For example:
stc_field_one:foo
stc_field_two:bar
Or:
field_one:foo
field_two:bar
All spaces around the colon sign are automatically stripped. Also, if the field’s name is omitted, the stc_name field is used by default. Therefore, if I wanted to create a task so that I remember to buy milk, I could simply send the following email:
To: task@stoic.com
Subject: create
Buy milk
Read (Explicit)
To read a record, send an email to it with the “read” subject. A reply is sent back with all the record’s field values. The reply is also sent to all recipients included in CC: in the original email.
Update (Explicit)
To update a record, do the same as Create, but with the “update” subject.
Delete (Explicit)
To delete a record, send an email to the record with the “delete” subject.
Action (Explicit)
To execute an action on an object (batch) or record (job), send an email to the object or the record, and put the action’s identifier (namespace optional) in the email’s subject, then set the action’s input parameters using the same syntax as the one used for Create or Update. For the namespace to be omitted, the stc_local_part field of the action must be set to the proper alias (namespace-free identifier). Alternatively, any other alias can be defined in that field.
Event (Explicit)
To create an event and add it to a record, send an email to the record with the “event” subject, and set the event’s field values using the same syntax as the one used for Create or Update.
Task (Explicit)
To create a task and add it to a record, do the same as for event, with the “task” subject.
Whenever an email is sent to an object or a record, an email reply is automatically sent to the original sender, as well as to all recipients included in CC: in the original email. This allows the sender to check that the email action was properly executed, or to be notified of some possible warnings and errors. This reply includes details about the action and hyperlinks to the object or record to which the email was sent, as well as to any relevant records. For example, if a custom action is executed on an object, the email reply includes a link to the record of the Batch object that is created in order to execute the action on all records of the object, or the records of a view defined as a parameter in the original email’s body.