Skip to main content

Message Format

Structure of messages received from the 8x8 Event Streaming service.

Pulsar WebSocket Message Structure

Messages received via the WebSocket connection follow the Pulsar WebSocket message format. Each message is a JSON object with the following structure:

{
"messageId": "CAEQAQ==",
"payload": "eyJldmVudElkIjogImV2dF8xMjM0NTYiLCAiZXZlbnRUeXBlIjogImFnZW50LmxvZ2luIn0=",
"properties": {},
"publishTime": "2025-10-15T09:30:00.000Z",
"redeliveryCount": 0
}

Field Descriptions

FieldTypeDescription
messageIdstringUnique identifier for this message (base64 encoded)
payloadstringThe actual event data (base64 encoded JSON)
propertiesobjectOptional metadata key-value pairs
publishTimestringTimestamp when the message was published (ISO 8601 format)
redeliveryCountnumberNumber of times this message has been redelivered

Payload Decoding

The payload field contains the actual event data, encoded in base64. To access the event data:

  1. Base64 decode the payload string
  2. Parse the result as UTF-8 JSON

Event Payload Structure

After decoding the base64 payload, you'll receive a JSON object representing the event. Events follow a structured format with common fields and event-specific data.

Common Event Fields

Most events include these common fields:

FieldTypeDescription
msgInfoobjectMetadata about the event (instanceId, sequenceId, timestamp)
msgInfo.instanceIdstringServer instance identifier
msgInfo.sequenceIdnumberEvent sequence number for ordering
msgInfo.timestampnumberEvent timestamp in milliseconds since epoch

Note: The msgInfo object provides important context about the event source and sequencing.

Interaction Event Fields

Interaction events (phone calls, chats, etc.) include additional common fields:

FieldTypeDescription
eventstringEvent type name (e.g., "InteractionCreated")
interactionGUIDstringUnique identifier for this interaction
interactionEventTSnumberInteraction event timestamp (seconds since epoch)
callStatestringCurrent call state (see Call States table below)
mediaTypestringCommunication channel
"phone"
"chat"
"email"
etc.
directionstringInteraction direction
"in" (inbound)
"out" (outbound)
attachedDataobjectAdditional metadata as key-value pairs
resourceTypenumberNumeric resource type identifier
agentIdstringAgent identifier (when agent is involved)
agentGUIDstringFull agent GUID (when agent is involved)
participatingAgentsstringComma-separated list of participating agent IDs
queueIdnumberQueue identifier
queueListnumberQueue list identifier
queueTimenumberTime when interaction entered queue (seconds since epoch)
eventTSnumberEvent timestamp (seconds since epoch)
transactionNumnumberTransaction number
recordingModestringRecording mode ("yes", "no")
isAgentInitiatedbooleanWhether interaction was initiated by agent
isDirectAccessbooleanWhether this is direct access interaction
isExternalbooleanWhether interaction involves external party
inboundChannelidmixedInbound channel identifier (number or "N/A" for outbound)
isOutboundCallbooleanWhether this is an outbound call

For detailed information about specific fields, see the Field Reference.

Call States

Interaction events use these call state values:

Call StateDescription
CS_IDLECall created, not yet in progress
CS_QUEUEDCall waiting in queue for an available agent
CS_INPROGRESSCall in progress (ringing or connecting)
CS_CONNECTEDCall connected and active
CS_HOLDCall on hold (music playing)
CS_DISCONNECTEDCall ended or hung up

For comprehensive call state documentation including transitions, see Field Reference - Call State Codes.

Event Lifecycle and Correlation

Events for an interaction are correlated using the interactionGUID field. To understand how events flow through an interaction's lifecycle, including state transitions, timing, and patterns for different call types, see the Event Lifecycle Guide.

Key points for event correlation:

  • Use interactionGUID to group all events for a single interaction
  • Track callState to monitor state transitions
  • Calculate durations using eventTS or interactionEventTS timestamps
  • Check hangupInitiator and callHangupReason in InteractionDeleted to understand outcomes

Attached Data Structure

The attachedData field contains an array of key-value pairs:

"attachedData": {
"attachedDatum": [
{"attachedDataKey": "phoneNum", "attachedDataValue": 5551234567},
{"attachedDataKey": "callingName", "attachedDataValue": "Alpaca Herd"},
{"attachedDataKey": "channelName", "attachedDataValue": "Support Queue"}
]
}

Common attached data keys include:

  • phoneNum: Phone number
  • callingName: Caller name
  • channelName: Channel/queue name
  • queueDirection: Queue direction (in/out)
  • tenantSkillName: Skill name
  • @pri: Priority value

For a comprehensive list of all attachedData keys, see the Field Reference.

Message Types

The WebSocket connection can receive several types of frames:

Text and Binary Messages

Most messages will be TextMessage or BinaryMessage types containing the Pulsar message JSON.

Control Messages

  • CloseMessage: Indicates the server is closing the connection
  • PingMessage: Heartbeat from server (respond with PongMessage)
  • PongMessage: Response to PingMessage

Most WebSocket libraries handle ping/pong automatically.

Processing Messages

Basic Processing Pattern

  1. Receive WebSocket message
  2. Parse the Pulsar message JSON to extract the payload field
  3. Base64 decode the payload
  4. Parse the decoded payload as JSON to get the actual event
  5. Process the event based on its type and data

Example: Complete Message Processing

// Read WebSocket message
messageType, message, err := conn.ReadMessage()
if err != nil {
return err
}

// Parse Pulsar message
var pulsarMsg PulsarMessage
if err := json.Unmarshal(message, &pulsarMsg); err != nil {
return err
}

// Decode payload
payload, err := base64.StdEncoding.DecodeString(pulsarMsg.Payload)
if err != nil {
return err
}

// Parse event
var event Event
if err := json.Unmarshal(payload, &event); err != nil {
return err
}

// Process event
processEvent(event)

Message Ordering

Messages are delivered in the order they were published to the topic. When reading from earliest, you'll receive all available historical messages in order before receiving new messages.

Event Sequence Examples

Understanding the sequence of events for common call scenarios helps when building integrations. The following examples show typical event flows with their EventType and callState values.

Inbound Call

StepActionEvent TypeCall State
1An incoming call from a customerInteractionCreatedCS_QUEUED
2The call goes into queue and is waiting to be assigned to an agentInteractionQueuedCS_QUEUED
3The call is assigned to an agentInteractionAssignedCS_QUEUED
4The agent accepts the call and speaks with the customerInteractionAcceptedCS_CONNECTED
5Automatic post processing starts (conclusion/wrapping up of call)InteractionPostProcessCS_DISCONNECTED
6Automatic post processing concludesInteractionEndPostProcessCS_DISCONNECTED
7The customer ends the callInteractionDeassignedCS_DISCONNECTED
8The agent ends the callInteractionDeassignedCS_DISCONNECTED

Outbound Call (No Queue)

StepActionEvent TypeCall State
1An outbound call is createdInteractionCreatedCS_IDLE
2The call is assigned to an agentInteractionAssignedCS_IDLE
3System starts recording the call legInteractionRecordingStartedN/A
4Call is in progress, ringing at destinationInteractionAcceptedCS_INPROGRESS
5Customer answers the callInteractionCustomerAcceptedCS_CONNECTED
6Call wrap-up process concludesInteractionEndPostProcessCS_DISCONNECTED
7Call is reassigned from agentInteractionDeassignedCS_DISCONNECTED

Call Transfer to Another Agent

StepActionEvent TypeCall State
1Original call in progressInteractionCreatedCS_IDLE
2First agent connected with customerInteractionAcceptedCS_CONNECTED
3First agent calls second agent (line 2)InteractionCreatedCS_IDLE
4Second agent's phone ringsInteractionAssignedCS_IDLE
5Second agent answersInteractionAcceptedCS_INPROGRESS
6First agent transfers call to second agentInteractionTransferRequestN/A
7First agent's wrap-up startsInteractionPostProcessCS_DISCONNECTED
8Second agent joins the callInteractionParticipantChangeCS_CONNECTED
9First agent's wrap-up concludesInteractionEndPostProcessCS_DISCONNECTED
10First agent deassignedInteractionDeassignedCS_DISCONNECTED

📘 Note

These are simplified examples. Real call flows may have additional events depending on features used (hold, recording, conferencing, etc.). See Event Reference for complete event type descriptions.

Sample Event Messages

The following examples show real event messages with actual field structures and values.

Agent Status Change

{
"AgentStatusChange": {
"agentId": "ag64oyEUb_Sk6bxVB9P5yaaa",
"msgInfo": {
"instanceId": "us1tomcat04.us1.whitepj.net-sapi-v1",
"sequenceId": 215,
"timestamp": 1669235544917
},
"newReasonCodeUser": "801=1722",
"newState": 5,
"newSubState": "none",
"newSubStateReason": "none",
"statusEventTS": 1669235544
}
}

Interaction Created (Incoming Call)

{
"Interaction": {
"attachedData": {
"attachedDatum": [
{
"attachedDataKey": "@pri",
"attachedDataValue": 100
},
{
"attachedDataKey": "callingName",
"attachedDataValue": "Andrew Cunningh"
},
{
"attachedDataKey": "cha",
"attachedDataValue": 13125555068
},
{
"attachedDataKey": "phoneNum",
"attachedDataValue": 5515557212
},
{
"attachedDataKey": "remoteCallingName",
"attachedDataValue": "Andrew Cunningh"
},
{
"attachedDataKey": "remotePhoneNum",
"attachedDataValue": "+15515557212"
}
]
},
"callState": "CS_QUEUED",
"event": "InteractionCreated",
"inboundChannelid": 13125555068,
"interactionEventTS": 1669235827,
"interactionGUID": "int-184a63564dc-ohWfVIbHJz2Hr2JFhAfdlb4Fa-phone-00-acmecorp01",
"msgInfo": {
"instanceId": "us1tomcat04.us1.whitepj.net-sapi-v1",
"sequenceId": 224,
"timestamp": 1669235827942
},
"resourceType": 0
}
}

Interaction Queued

{
"Interaction": {
"attachedData": {
"attachedDatum": [
{
"attachedDataKey": "channelName",
"attachedDataValue": "Acme Ads OG"
},
{
"attachedDataKey": "que",
"attachedDataValue": "acmecorp01~~queue~~phone~~591"
},
{
"attachedDataKey": "queueDirection",
"attachedDataValue": "in"
},
{
"attachedDataKey": "priority",
"attachedDataValue": 50
},
{
"attachedDataKey": "tenantSkillName",
"attachedDataValue": "Test Sales"
}
]
},
"callState": "CS_QUEUED",
"direction": "in",
"event": "InteractionQueued",
"eventTS": 1669235836,
"inboundChannelid": 13125555068,
"interactionEventTS": 1669235836,
"interactionGUID": "int-184a63564dc-ohWfVIbHJz2Hr2JFhAfdlb4Fa-phone-00-acmecorp01",
"isAgentInitiated": false,
"mediaType": "phone",
"msgInfo": {
"instanceId": "us1tomcat04.us1.whitepj.net-sapi-v1",
"sequenceId": 225,
"timestamp": 1669235836708
},
"priority": 50,
"queueId": 591,
"queueList": 591,
"queueTime": 1669235836,
"resourceType": 0,
"transactionNum": 19727
}
}

Interaction Deleted (Call Ended)

{
"Interaction": {
"attachedData": {
"attachedDatum": [
{
"attachedDataKey": "callingName",
"attachedDataValue": "Andrew Cunningh"
},
{
"attachedDataKey": "phoneNum",
"attachedDataValue": 5515557212
},
{
"attachedDataKey": "remotePhoneNum",
"attachedDataValue": "+15515557212"
}
]
},
"callHangupReason": "CEC_DISCONNECT_NORMAL",
"callState": "CS_DISCONNECTED",
"dispositionCode": 1000,
"event": "InteractionDeleted",
"hangupInitiator": "CUSTOMER",
"inboundChannelid": 13125555068,
"interactionEventTS": 1669236911,
"interactionGUID": "int-184a645e074-zGIsMxOkCYzQ8yg68e3t61i7A-phone-00-acmecorp01",
"isAgentInitiated": false,
"isDirectAccess": false,
"isQueued": false,
"mediaType": "phone",
"msgInfo": {
"instanceId": "us1tomcat04.us1.whitepj.net-sapi-v1",
"sequenceId": 251,
"timestamp": 1669236911188
},
"recordingMode": "no",
"rejectReason": 0,
"resourceType": 0
}
}

Next Steps