SDK
Build with Periskope using our Typescript SDK
The Periskope Typescript client exposes our RESTful APIs with complete type-safety, semantically named functions, and straightforward JSON responses. Whether you’re building bots, automating customer support, sending messages, managing tickets, or creating groups, Periskope Client makes it quick and efficient to integrate Periskope into your workflow.
We encourage responsible usage of the APIs. Follow these best practices and recommendations for safe actions on WhatsApp - https://docs.periskope.app/get-started/best-practices
Prerequisites
- Sign up for a free account on Periskope: To use the Periskope Client, you need to have an active Periskope account. If you don’t have one, you can sign up for a 7-day free trial here.
- Scan the QR code from WhatsApp to connect your phone: A connected phone is required to use the package
- Generate an API Key: An API key is required for authentication and can be generated from your Periskope settings here.
Setup Guide
Install Node.js
If you don’t already have Node.js installed, download it from the official Node.js website.
We recommend installing the LTS version for better stability.
You can verify your installation by running:
Install the Periskope Client SDK
Use your preferred package manager to install the official Periskope client:
Use the SDK in your project
Here’s a basic example of how to use the Periskope client in your code:
You're ready to go ✅
That’s it! You’ve set up Node.js, installed the Periskope client SDK, and made your first API call using JavaScript or Typescript.
You can now explore more features like creating groups, raising tickets, and listening to webhooks.
Webhooks
Periskope emits various webhook events that you can listen to in real-time using the SDK. These events allow your application to respond automatically to activities like incoming messages, status changes, and other WhatsApp interactions. For a comprehensive overview of all webhook events and their payloads, check out our Webhooks docs.
The SDK provides an event emitter interface that makes it easy to subscribe to these events without setting up a separate webhook server.
Usage
Here’s a basic example of how to subscribe to the message.created event using the Typescript package:
Available Webhook Events
The SDK supports listening to various event types including:
chat.created
- Triggered when a new chat is created 🔗chat.notification.created
- Triggered when a new chat notification is created 🔗message.created
- Triggered when a new message is received or sent 🔗message.updated
- Triggered when message is edited 🔗message.deleted
- Triggered when message is deleted 🔗message.ack.updated
- Triggered when a message is acknowledged 🔗message.flagged
- Triggered when a message is flagged 🔗message.unflagged
- Triggered when a message is unflagged 🔗reaction.created
- Triggered when a reaction is created 🔗reaction.updated
- Triggered when a reaction is updated 🔗ticket.created
- Triggered when a new ticket is created 🔗ticket.updated
- Triggered when a ticket details are updated 🔗ticket.deleted
- Triggered when a ticket is deleted 🔗
Implementing Event Handlers
You can implement multiple event handlers to build comprehensive automations:
Was this page helpful?