Module: messaging

Copyright 2020 Parsable, Inc
API address: /api/messages

ModuleServicesData typesConstants
messagingMessagingService
FieldPtr
GetMessageOptions
GetMessagesResult
JobPtr
Message
MessageBatchEntry
MessageBatchResult
MessageCategory
MessageResult
MetadataPtr
NoticesPtr
PpePtr
ReceiverType
ResourcePtr
ResourceType
StepGroupPtr
StepPtr
StructuredBody
TemplateResource
TemplateThreadPtr
Thread
ThreadMessageCategory
ThreadMessageResult
ThreadParams
ThreadPtr
ThreadQueryResult
ThreadState
ThreadWhereOpts
TitlePtr

Enumerations

Enumeration: MessageCategory

Client should not set MessageCategory, server assumes UserMessage as category

USER_CHAT1
STATUS_ADD_USER2
STATUS_COMPLETE_STEP3
STATUS_COMPLETE_JOB4
STATUS_ADD_STEP5
STATUS_ADD_DOCUMENT6
STATUS_ADD_DOCUMENT_BY_EMAIL7
STATUS_CREATE_JOB8
USER_PING9
STATUS_START_JOB10
STATUS_APPLICABLE_STEP11
STATUS_NON_APPLICABLE_STEP12
STATUS_REMOVE_USER13
STATUS_REMOVE_DOCUMENT14
STATUS_UNCOMPLETE_JOB15
STATUS_UNCOMPLETE_STEP16
STATUS_CONDITIONAL_YES17
STATUS_CONDITIONAL_NO18
STATUS_APPLICABLE_STEP_GROUP19
STATUS_NON_APPLICABLE_STEP_GROUP20
STATUS_APPLICABLE_FIELD21
STATUS_NON_APPLICABLE_FIELD22
STATUS_JOB_CREATED_ISSUE23 New issue created from job
STATUS_CREATE_ISSUE_ON_JOB24
STATUS_RESOLVE_ISSUE_ON_JOB25
STATUS_COMPLETE_JOB_ON_ISSUE26 Job referenced by issue was completed
STATUS_ADD_ROLE27
STATUS_REMOVE_ROLE28
STATUS_REOPEN_JOB29
STATUS_REOPEN_ISSUE30
STATUS_REOPEN_STANDALONE_ISSUE31
STATUS_RESOLVE_STANDALONE_ISSUE32
STATUS_COMMENT_THREAD33
STATUS_UPDATE_DOCUMENT34
STATUS_ARCHIVE_JOB35
STATUS_TEMPLATE_UPDATE_FOR_JOB36
STATUS_APPLET_TRIGGERED37
STATUS_CANCEL_JOB38
STATUS_UNCANCEL_JOB39
DISMISSED_USER_DATA40

Enumeration: ThreadMessageCategory


USER1
STATUS_RESOLVE2
STATUS_UNRESOLVE3

Enumeration: ResourceType

Indicates the object referenced by the corresponding message argument

JOB1
USER2
STEP3
DOCUMENT4
JOB_ROLE5
ALL_USERS_IN_JOB6 All users in the job. No id required in Template Resource. Used in @All pings
FIELD7
OTHER8
LOOKUP_ID9

Enumeration: ReceiverType


ALL1 receiverId is null
ROLE2 receiverId is jobRoleId
USER3 receiverId is userId
NONE4 receiverId is null

Enumeration: ThreadState


RESOLVED1
UNRESOLVED2

Data structures

Struct: MetadataPtr

KeyFieldTypeDescriptionRequirednessDefault value
1idstringdefault

Struct: TitlePtr

KeyFieldTypeDescriptionRequirednessDefault value

Struct: PpePtr

KeyFieldTypeDescriptionRequirednessDefault value

Struct: NoticesPtr

KeyFieldTypeDescriptionRequirednessDefault value

Struct: FieldPtr

KeyFieldTypeDescriptionRequirednessDefault value
1clientIdstringdefault

Struct: StepPtr

KeyFieldTypeDescriptionRequirednessDefault value
1idstringId of the referenced step. Within the context of a job, this should be set to the jobBaseStepId default
2clientIdstringClientId is needed for elements that change their ID throughout versions. default
10metadataPtrMetadataPtroptional
11fieldPtrFieldPtroptional
12titlestringoptional

Struct: StepGroupPtr

KeyFieldTypeDescriptionRequirednessDefault value
1idstringId of the referenced step. Within the context of a job, this should be set to the jobBaseStepId default
2clientIdstringClientId is needed for elements that change their ID throughout versions. default
10ppePtrPpePtroptional
11noticesPtrNoticesPtroptional
12titlestringoptional

Struct: JobPtr

KeyFieldTypeDescriptionRequirednessDefault value
1idstringid of the job this struct is referencing. default
2jobTypei32type of this job
reason we don't use job type enum is to avoid circular dependecy (job already refers here)
also since default jobType is 0 which happens to be the Normal type that is the only possible
one (issue referring to source normal job), before the advent of on-demand instances starting
from on-demand jobs (normal referring to source ad hoc job).
default
10stepPtrStepPtroptional
11stepGroupPtrStepGroupPtroptional
12titlestringoptional

Struct: TemplateThreadPtr

KeyFieldTypeDescriptionRequirednessDefault value
1idstringid of the template this struct is referencing. default
10stepPtrStepPtroptional
11stepGroupPtrStepGroupPtroptional
12titlePtrTitlePtroptional
13ppePtrPpePtroptional
14noticesPtrNoticesPtroptional

Union: ThreadPtr

KeyFieldTypeDescriptionRequirednessDefault value
1templatePtrTemplateThreadPtrdefault

Union: ResourcePtr

KeyFieldTypeDescriptionRequirednessDefault value
1jobPtrJobPtrdefault

Struct: TemplateResource

KeyFieldTypeDescriptionRequirednessDefault value
1typResourceTypedefault
2idstringValue depends on ResourceType value USER, JOB, DOCUMENT, JOB_ROLE: id of resource STEP (includes step groups): jobBasedStepId of resource FIELD: comma separated jobBasedStepId of parent step and fieldId ALL_USERS_IN_JOB: empty OTHER: empty default
3labelstringdefault
4ptrResourcePtr * This will be set if ResourceType is Other * optional

Struct: StructuredBody

KeyFieldTypeDescriptionRequirednessDefault value
1resourceLocatormap<string, TemplateResource>default
2tmplstringdefault

Struct: GetMessageOptions

KeyFieldTypeDescriptionRequirednessDefault value
1canHandlePendingDocumentsboolThis must be set to true to know you can handle messages containing documents which are not yet uploaded but are “pending” and hopefully will be sent soon. defaultfalse
2beforeSeqIdboolIf this is true, then client is requesting messages from _before_ the sequence id, not from _after_ it. defaultfalse
3limiti32This is the number of messages to be retrieved at a time. Any value less than one is considered to be the maximum allowed. The maximum allowed is defined on the server. At present, it is 10K. default0

Struct: Message

KeyFieldTypeDescriptionRequirednessDefault value
1idstringdefault
2jobIdstringdefault
3seqIdi64default
4clientCreatedAti64timestamp when message was created on client - in seconds default
5categoryMessageCategorydefault
6senderIdstringdefault
7receiverTypeReceiverTypedefault
8receiverIdstringdefault
9bodystringdefault
10serverCreatedAti64timestamp when message was received by server - in seconds default
11structuredBodyStructuredBodyArgs used to populate template. Key is template argument name optional
12targetStepstep.BaseStepDeprecated. Use structured body to send structured messages. Set to target step when sending a ping messsage for a step optional
50documentslist<document.Document>Send documents with isPending = true & empty ids to reserve documentIds; these will be returned in the order they were passed in, but with the ID filled in. If the mimeType and size are provided, the receiving end can be clever about its UI to display progress. On Get, messages containing any pending documents will only be returned if the option canHandlePendingDocuments is set to true. default
51updatedSeqIdi64If this is an update to a previous message that had a pending document, this is a reference to the earlier message that is now updated. If several modifications happen to same user-facing message this will still point to the original seqId (the anchoring location) and not subsequent ones. optional
200deviceIdstringFor Mesh optional
201deviceSeqIdi64optional

Structured body contains a rich message body of the following format:

Template example:

 messageTemplate: "{{user}} added document {{doc}}",
 tmpl:
   "user": { "typ": User, "id": someUUID, "label": UserName },
   "doc": { "typ": Document, "id": someUUID, "label": DocName },
To display messages as a client, the client should take the following steps:
  1. Detect all sequences in the template matching \{\{([^}]+\}\}, anything inside double braces {{}}
  2. Within those sequences, the text should correspond to an entry in the resourceLocator
  3. Use the ResourceType of the entry to determine object type
  4. If the Label field is populated, use the label as the display name. If not, use the Id and Type fields to fetch the appropriate object and label


Sending a strutured message

In order to send structured data, follow the format above when constructing a message struct to send to the server. The server will prioritize the StructuredBody field over the body field when present. In order to escape "{{" and "}}" replace with "\{{" and "\}}" respectively. The clients will be responsible for unescaping. Escape format is defined for consistency across clients.

Struct: Thread

KeyFieldTypeDescriptionRequirednessDefault value
1idstringdefault
2creatorIdstringdefault
3topicstringdefault
4stateThreadStatedefault
5ptrThreadPtrInformation specifying the object the thread is referencing default
10createdAti64default
20lastActivityAti64Timestamp of the last activity on this thread. Populated in QueryThreads optional

Struct: MessageResult

KeyFieldTypeDescriptionRequirednessDefault value
1idstringdefault
2seqIdi64default
3messageslist<Message>Messages, which will contain assigned IDs for pending documents default

Struct: MessageBatchEntry

KeyFieldTypeDescriptionRequirednessDefault value
1messageMessageoptional
2errcommon.SystemExceptionoptional

Struct: MessageBatchResult

KeyFieldTypeDescriptionRequirednessDefault value
1entrieslist<MessageBatchEntry>default

Struct: GetMessagesResult

KeyFieldTypeDescriptionRequirednessDefault value
1seqIdi64The maximum seqId from the accompanying messages list default
2messageslist<Message>default

Struct: ThreadParams

KeyFieldTypeDescriptionRequirednessDefault value
1stateThreadStateoptional

Struct: ThreadMessageResult

KeyFieldTypeDescriptionRequirednessDefault value
1nodeVersioncore_event.NodeVersiondefault

Struct: ThreadWhereOpts

KeyFieldTypeDescriptionRequirednessDefault value
1templateIdstringoptional

Struct: ThreadQueryResult

KeyFieldTypeDescriptionRequirednessDefault value
1threadslist<Thread>default


Services

Service: MessagingService

Function: MessagingService.send

MessageResult send(string jobId,
                   Message message)
    throws common.SystemException
Send a message in a given job

Function: MessagingService.sendBatch

MessageBatchResult sendBatch(string jobId,
                             list<Message> messages)
    throws common.SystemException
Send a batch of message in a given job returns a list MessageBatchEntrys in the same order as the given list with the message on success or an error

Function: MessagingService.get

GetMessagesResult get(string jobId,
                      i64 seqId,
                      GetMessageOptions options)
    throws common.SystemException
Get messages in a given job

Function: MessagingService.createThread

Thread createThread(ThreadPtr threadPtr)
    throws common.SystemException
Create a new Message Thread under an element of a Template or Job

Function: MessagingService.sendToThread

ThreadMessageResult sendToThread(string threadId,
                                 Message message)
    throws common.SystemException
Send a message in a given message thread

Function: MessagingService.queryThreads

ThreadQueryResult queryThreads(ThreadWhereOpts whereOpts)
    throws common.SystemException
Query threads, ordered by last activity by default

Function: MessagingService.updateThread

core_event.NodeVersion updateThread(string threadId,
                                    ThreadParams params)
    throws common.SystemException
Update thread details. Can only update thread state, for now