Skip to content

Apps to Core communication protocol

Jason Shin edited this page Sep 5, 2017 · 11 revisions

The communication protocol is based on WebSocket at the moment with Socket.io support. Apps to Core messages have guaranteed destination, which is the core server. Core to Apps communication is using socket.io broadcasting feature. Core broadcasts a message using a unique id to all the apps and it is apps' responsibility to be able to pick up the messages.

Apps to Core communication

Name Description Key: string Payload
Register App Signals core to register current app to the database REGISTER_APP jump
Incoming action App received a message from external source INCOMING_MESSAGE jump
Ping Pings the core to check uptime PING jump

1. Register App Payload

type: json

Name Required description
name true Unique name used by the system
label true Name used to display in the frontend
version true version of the app. It can be "latest" or numerical values in "{d}.{d}.{d}" pattern
description false description of the app
icon false icon of the app
incomingActions true list of incoming actions (triggered by external APIs. see details
outgoingActions true list of outgoing actions (apps use them to trigger external APIs) see details
incomingActions payload

type: json

key: name of the incomingAction

Name Required description
type false ?
name false ?
description false description about this action
conditions false List of conditions it can have accoding to incoming payload (e.g. message container xx)
fields true Describes structure of json payload
options false list of options ??

Example Register app payload

{
  name: 'biphub-discord',
  label: 'Discord',
  description: `Step up your game with a modern voice & text chat app. Crystal clear voice,
  multiple server and channel support, mobile apps, and more.`,
  instructions: 'https://discordapp.com/developers/docs/intro',
  icon: 'icon-discord.png',
  incomingActions: {
    message: {
      type: 'webhook/ws',
      name: 'message',
      description: 'Message event that triggers when there is a new message',
      conditions: {
        matches: {
          name: 'matches',
          required_fields: ['content']
        },
        contains: {
          name: 'contains',
          required_fields: ['content']
        }
      },
      fields: {
        content: { type: 'string', name: 'content' }
      },
      options: {
        channel: { type: 'string', name: 'channel' }
      }
    }
  },
  outgoingActions: [
    { name: 'createCard' },
    { name: 'deleteCard' }
  ]
}