Messaging API

The Messaging Service provides implementations to support sending messages and alerts under a coherent REST API. Service instances can be added and removed via REST API. Messages can be scheduled or sent immediately.

Attributes

The Messaging API supports the generic concept of a message, and each implementation interprets attributes in context. For example, "to:" in the context of a Slack message references the intended channnel, whereas "to:" in the context of an email(SMTP) references the intended email address of its recipient.

Message Attribute Description

id

An application specific id for tracking the message. Must be unique.

type

The type of message to send, one of the following: * log * smtp * slack

to

One or more destinations for the message, as a list

from

Who/what the message is from

subject

The subject of the message

body

The main body of the message

schedule

Used to pass messages at a later time, or at a recurring basis.

messageServiceParams

Passes a map of any service-specific parameters, such as the user name and password

Add or Display a list of messaging service instances

The path for this request is:

api/apollo/messaging/service
  • GET - lists all active instances.

  • POST - adds a new MessageService instance.

Send a message

The path for this request is one of:

api/apollo/messaging/send
api/apollo/messaging/send/<type>/<id>
  • POST - sends the message, where type specifies the type of message, and id specifies which message if there is more than one

  • PUT - sends scheduled message.

Schedule messaging

Fusion will automatically fill in the Schedule Call Params. The path for this request is:

apollo/messaging/schedule
apollo/messaging/schedule/<id>

POST schedule one or more messages. Each Message has an associated Schedule object that is used to schedule that item.
PUT: Update a Message that has been scheduled. This only works for unsent or repeating Messages that have been scheduled.
DELETE: Deletes a Message that has been scheduled. This only works for unsent or repeating Messages that have been scheduled.

Check message status

To GET message services status, the path is:

api/apollo/messaging/status

Examples

Display current messaging services:

REQUEST

curl -u user:pass http://localhost:8764/api/apollo/messaging/service

RESPONSE

[ {
"type": "logging-message-service-config",
"defaultLogLevel" : "info",
"template": "<to>:<from>:<subject>:<body>",
"serviceType": "log"
} ]

Send a message using Slack

REQUEST

curl -u user:pass -X POST -H 'Content-Type: application/json' -d  '{"id": "myID", "type": "slack", "subject": "test", "body": "@recipient: this is a test", "to": ["recipient"], "from": "sender"}' http://localhost:8764/api/apollo/messaging/send

RESPONSE

[ {   "id": "myID",
    "type": "slack",
    "subject": "test",
    "body": "@recipient: this is a test",
        "to": "recipient",
    "from": "sender"
} ]
Get all scheduled messages
curl -u user:pass http://localhost:8764/api/apollo/messaging/scheduled

RESPONSE

[
 {
   "id": "myID",
   "type": "slack",
   "subject": "Updates",
   "body": "@recipient:here is the latest version",
   "to": ["updatechannel"],
   "from": "sender",
   "schedule":{"id":"slack", "creatorType":"human", "creatorId":"admin", "repeatUnit":"DAY", "interval":1, "startTime":"2015-05-21T06:44:00.000Z", "active":true}
 }

Show the current status of messaging services:

REQUEST

curl -u user:pass http://localhost:8764/api/apollo/messaging/status

RESPONSE

[ {
  "status" : "ok",
  "node" : "http://xxx.xx.xx.x:8764/api/apollo/messaging",
  "messages" : [ ]
} ]