import { PeriskopeApi } from '@periskope/periskope-client';

const client = new PeriskopeApi({
  authToken: 'YOUR_API_KEY',
  phone: 'YOUR_PHONE_NUMBER', // e.g., '919876543210'
});

client.on('chat.created', (data) => {
  console.log(data);
});

Refer Chat object to find more details about chat object.

import { PeriskopeApi } from '@periskope/periskope-client';

const client = new PeriskopeApi({
  authToken: 'YOUR_API_KEY',
  phone: 'YOUR_PHONE_NUMBER', // e.g., '919876543210'
});

client.on('chat.created', (data) => {
  console.log(data);
});

Event structure 📦

You’ll be receiving the data in the following format:

{
  "event": "<event-type>",
  "data": "<event-data>", // complete data object as mentioned in Objects section
  "org_id": "<your-organisation-id>",
  "previous_attributes": "<previous-attributes>", // attributes changes in new object. In case of an update event.
  "timestamp": "<timestamp>" // timestamp of the event creation
}