Nitrogen Peroxide Monoxide

    @kiina/facebook-tools

    2.1.4 • Public • Published

    Facebook Tools

    This package contains some Facebook tools, which can be used to help in the use of some of Facebook's APIs.

    Installation

    npm install @kiina/facebook-tools
    

    Table of contents

    1. Broadcast
    2. ThreadControl

    Broadcast

    Offers resources to access the Facebook's Broadcast API.

    Usage

    const { Broadcast } = require('@kiina/facebook-tools');
    
    const broadcast = new Broadcast('<FB-PAGE-TOKEN>');

    Methods

    createLabel(labelName: string): Promise

    Creates a new label to use on broadcasts.

    const labelName = 'LABEL_NAME';
    await broadcast.createLabel(labelName);

    addUserToLabel(userId: string, labelName: string): Promise

    Add an user to an existing label.

    const labelName = 'LABEL_NAME';
    await broadcast.addUserToLabel('<FB-USER-ID>', labelName);

    removeUserFromLabel(userId: string, labelName: string): Promise

    Removes an user from an existing label.

    const labelName = 'LABEL_NAME';
    await broadcast.removeUserFromLabel('<FB-USER-ID>', labelName);

    sendMessages(messages: FacebookMessage[], labelName: string): Promise

    Sends a list of messages to an existing label.

    const labelName = 'LABEL_NAME';
    const messages = [
      { text: 'hello world' }
    ];
    
    await broadcast.sendMessages(messages, labelName);

    Reference: FacebookMessage - https://developers.facebook.com/docs/messenger-platform/reference/send-api/#message

    Thread Control

    Offers resources to access the Facebook's Thread Control API.

    Usage

    const { ThreadControl } = require('@kiina/facebook-tools');
    
    const threadControl = new ThreadControl('<FB-PAGE-TOKEN>');

    Methods

    passThreadControl(userId: string, targetAppId: string, metadata?: string): Promise

    Passes the control of the conversation with the given user to a different app.

    const userId = '2153176358137612538';
    const targetAppId = '539126537823531312';
    const metadata = 'some payload you might want to send'
    await threadControl.passThreadControl(userId, targetAppId, metadata);

    takeThreadControl(userId: string, metadata?: string): Promise

    Takes back the control of the conversation with the given user.

    const userId = '2153176358137612538';
    const metadata = 'some payload you might want to send'
    await threadControl.takeThreadControl(userId, metadata);

    Keywords

    none

    Install

    npm i @kiina/facebook-tools

    DownloadsWeekly Downloads

    1

    Version

    2.1.4

    License

    ISC

    Unpacked Size

    13.5 kB

    Total Files

    12

    Last publish

    Collaborators

    • asalgado
    • eder_kiina
    • antunesmg
    • marcojardim