Workplace
This is a wrapper for the Workplace Platform API. It has been designed to be easily used with promises. The api docs can be seen at: https://developers.facebook.com/docs/workplace/integrations/custom-integrations/reference
Table of Contents
Getting Started
To install the package, simply run:
npm install workplace --save
Then, simply load up the package and set the access token:
const WP = ;WP;
API Reference
Making a Post
Once the package is set up, you can post to a group like this:
const groupID = <YOUR_GROUP_ID>;const data = message: 'text body of the message' url: 'example.com/my_photo.jpg' // optional photo url with your post;let response = await WP;
Sending Messages
Workplace integrations have the ability to send a variety of message types directly or to groups of individuals. Specifically, you can send:
- Text
- Images
- Videos
- Audio
- Templates
This wrapper includes a few useful abstractions to make sending a message simple.
Use the WP.Message
namespace to construct a message of various types:
To send a text message, use the WP.Message.Text
wrapper to generate your message
// text messagesconst message = WPMessage; // hosted and local imagesconst imageMessageFromURL = WPMessage;const localImageMessage = WPMessage; // hosted and local videosconst videoMessageFromURL = WPMessage;const localVideoMessage = WPMessage; // hosted and local audio filesconst audioMessageFromURL = WPMessage;const localAudioMessage = WPMessage; // send a custom json message templateconst messageTemplate = WPMessage
Then specify IDs and send the message away!
await WP;
FB API Object
The FB API is directly exposed for anything that this API wrapper does not include. It can be accessed in the following way:
const fbAPI = WPapi;
This API is taken from the npm package FB
Made with <3 in London