Skip to content

Latest commit

 

History

History

typescript-server

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Graph API Webhook TypeScript Sample

This is a sample client for Facebook's Webhooks product and Instagram's Subscriptions API, powered by Node.js and written in TypeScript.

Setup

Prerequisites

Ensure you have Node.js installed. Create a .env file in the typescript-server directory with the following content:

APP_SECRET=your_app_secret
TOKEN=your_verify_token
FROM_PHONE_NUMBER_ID=your_phone_number_id
WHATSAPP_BEARER_TOKEN=your_app__bearer_token

Instalation

  1. Navigate to the typescript-server directory:
    cd typescript-server
  2. Install the dependencies:
    npm install

Running the Server

  1. Start the server in development mode:
    npm run dev
  2. Alternatively, build and start the server:
    npm start

Facebook Webhooks

  1. Refer to Facebook's Webhooks sample app documentation to see how to use this app.
  2. Set up your Facebook application's Graph API Webhooks subscription using https://<your-domain>/facebook as the callback URL.

Instagram Subscription API

  1. Register an Instagram API client.

  2. Set up your client's subscription using https://<your-domain>/instagram as the callback URL.

Threads Webhooks

  1. Refer to Threads' Webhooks Documentation and set up Threads Webhooks product as a sub use case under the Threads API main use case.
  2. Set up your webhooks callback URL as https://<your-domain>/threads.

Endpoints

POST /facebook - Handles Facebook webhook events.
POST /instagram - Handles Instagram webhook events.
POST /threads - Handles Threads webhook events.
POST /whatsapp - Handles WhatsApp webhook events.
POST /message - Sends a WhatsApp message.

License

This project is licensed under the MIT License.