Messages exchanged by Node-RED nodes are JavaScript objects look like

{
  /* some keys */
  payload: 'some content from the previous node'
}

Generally each node put the result of its computation in the payload key of the message after cloning the incoming message, any other key except payload is left untouched.

All RedBot receivers work in this way: the incoming message of the different platforms (Telegram, Slack, etc.) is translated in a common format and stored in the payload key of the message. All informations to keep track of the current chat in the originalMessage key.

In this way every node between a receiver and a sender can make any kind of computation, since every node changes just the payload value, the sender node will always be able to handle a proper response using the information of originalMessage.

For an incoming text message “I am a message”, this will be the incoming message

{
  originalMessage: {
    // internal values (userId, chatId, etc.
  },
  payload: {
    // the type of used platform
    transport: 'telegram',
    // the unique identifier of the user within the platform (in this case Telegram)
    chatId: '123456',
    // the unique identifier of the user in RedBot (the same user could access the same 
    // bot with different platforms, one userId -> many chatIds)
    userId: '456789',
    // the type of the message
    type: 'message',
    // received or sent message
    inbound: true,
    // the content of the message
    content: 'I am a message'
  },
  // returns the chat context for the current user
	chat: // function,
  // returns the chat-platform instance
  api: // function,
  // returns the internal client used by the chat-platform to handle the specific platform 
  client: // function
}

After a text message (i.e., Hello!) is sent through a sender node (i.e., Telegram Sender node) the Node-RED message will look like

{
  originalMessage: {
    // internal values (userId, chatId, etc.
  },
  sentMessage: {
    // the type of the message send from RedBot
    type: 'message',
    // the unique identifier of the user within the platform (in this case Telegram)
    chatId: '123456',
    // the unique identifier of the user in RedBot
    userId: '456789',
    // the id of the message sent to the user from RedBot
    // use this id to modifiy a previously sent message
		messageId: '01234567890',
    // is an outbound message
		inbound: false
  },
	// returns the chat context for the current user
	chat: // function,
  // returns the chat-platform instance
  api: // function,
  // returns the internal client used by the chat-platform to handle the specific platform 
  client: // function
}

The content key it’s a String for plain text messages, Buffer for images and files, etc.

The msg object has also some methods:

Method Return Description
.chat() instance of ChatContext() Returns the current chat context, a persisted memory space related to the current user, see ‣ for more information
.client() Object / Class Returns the underlying class used for a specific platform, depends on the platform: ‣ , ‣ . Use this to get the wrapped class and access features of a specific platform not yet implemented in RedBot
.api() instance of ChatPlatform() ChatPlatform is a wrapper for third party platform libraries, it translates incoming messages into a common format suitable for RedBot, it’s unlikely you’ll need this