Registry / communication / ciscospark-websocket-events

ciscospark-websocket-events

JSON →
library1.2.0jsnpmunverified

A Node.js library (v1.2.0, no recent updates) that connects to Cisco Spark's native WebSocket and emits events for message creation, membership creation, and room updates. Designed for bots behind firewalls that cannot receive inbound webhooks. Supports event callbacks and forwarding events to a configurable webhook URL. Works with BotKit. Note: Cisco Spark has been rebranded to Webex; this library targets the legacy API.

npm install ciscospark-websocket-events
INSTALL
IMPORT
SIG · CISCOSPARK-WEBSOCK
C
ciscospark-websocket-events
communicationjavascriptv1.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SparkWebSocket
const SparkWebSocket = require('ciscospark-websocket-events')
import SparkWebSocket from 'ciscospark-websocket-events'
The package does not ship ESM exports or TypeScript types; use CommonJS require.
new SparkWebSocket(accessToken)
const sparkwebsocket = new SparkWebSocket(process.env.SPARK_TOKEN ?? '')
new SparkWebSocket(null) or new SparkWebSocket()
The constructor requires a valid access token string; passing undefined or null may cause connection errors.
sparkwebsocket.connect()
sparkwebsocket.connect(function(err, res) { ... })
sparkwebsocket.connect().then(...)
connect() does not return a Promise; use a callback to handle success/error.
sparkwebsocket.setEventCallback()
sparkwebsocket.setEventCallback(function(event) { ... })
sparkwebsocket.on('event', callback) or sparkwebsocket.addEventListener
The library does not emit Node.js events; use the dedicated callback method.
sparkwebsocket.setWebHookURL()
sparkwebsocket.setWebHookURL('http://example.com/webhook')
sparkwebsocket.setWebhookURL('http://example.com') (wrong casing)
Method name uses mixed case: 'WebHookURL' (capital H and U).

Shows how to initialize the library, connect to the WebSocket, and register an event callback to handle incoming events.

const SparkWebSocket = require('ciscospark-websocket-events'); const accessToken = process.env.SPARK_TOKEN ?? ''; const sparkwebsocket = new SparkWebSocket(accessToken); sparkwebsocket.connect((err, res) => { if (err) { console.error('Connection error:', err); return; } console.log('Connected to Cisco Spark WebSocket'); sparkwebsocket.setEventCallback((event) => { console.log('Received event:', JSON.stringify(event, null, 2)); }); });
Debug
Known issues
deprecatedCisco Spark has been rebranded to Webex Teams; this library targets the legacy API and may stop working.
fix
Migrate to the official Webex JS SDK (@webex/webex) which supports WebSocket events natively.
affects: >=0.0.0
gotchaThe library does not automatically reconnect on WebSocket close. Once the connection drops, events stop.
fix
Implement manual reconnection logic by listening to the WebSocket 'close' event and calling connect() again.
affects: >=0.0.0
gotchaThe constructor expects a single argument (access token) but does not validate it; passing an invalid token leads to cryptic errors.
fix
Ensure the access token is a non-empty string. Test by using the Cisco Spark REST API beforehand.
affects: >=0.0.0
gotchaThe webhook URL forwarded events do not include authentication headers; the target endpoint must handle security on its own.
fix
Use an API key or IP whitelisting on the webhook endpoint to verify incoming requests.
affects: >=0.0.0
Errors
Common errors & fixes
Error starting up websocket: Error: getaddrinfo ENOTFOUND api.ciscospark.com
Network failure or DNS resolution issue for the Cisco Spark API endpoint.
fix
Check internet connectivity and DNS settings. If behind a firewall, ensure outbound HTTPS to api.ciscospark.com is allowed.
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'on' of undefined
The connect callback was not called, or the WebSocket instance was not created due to missing access token.
fix
Verify that accessToken is defined and valid. Add a check before calling sparkwebsocket.connect().
TypeError: sparkwebsocket.setEventCallback is not a function
The connect callback might have failed, leaving sparkwebsocket in an incomplete state.
fix
Only call setEventCallback inside the connect callback after ensuring no error. Check connection.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
39 hits · last 30 days
node
30
OpenAI (training)
2
Amazon
1
Resources
ciscospark-websocket-events — npm install ciscospark-websocket-events · libregistry