Step 1: Set up the Facebook App
1. Create a Facebook Developer Account
- Visit Facebook Developer Console (https://developers.facebook.com).
- Sign up and log in using your Facebook account.
2. Create a New Facebook App
- Click on My Apps at the top right.
- Select Create App.
- Choose For Everything Else and fill in the app details.
- Click Create App ID.
3. Set Up Facebook Graph API
- In your Facebook App Dashboard, find Facebook under “Add a Product” on the left.
- Click Set Up under Messenger API Setup.
- This will enable Messenger API capabilities in your app.
4. Create or Use an Existing Facebook Page
- If you don’t have a Facebook Page, create one by going to your Facebook account and creating a Page.
- Go to Create a Page and choose the appropriate category (e.g., Business or Brand).
- Your Facebook Page is required to interact with Messenger and to generate access tokens.
5. Link the Facebook Page to the App
- Go to the Messenger product section within the Facebook Developer portal.
- Under the Token Generation section, you will see an option to Connect to Facebook using your account.
- Log in to your Facebook account and choose the Page that you want to use for Messenger interactions.
- If you don’t see your Page listed, ensure you’re an admin of the Page and have permissions to manage it via the Facebook Developer portal.
6. Generate a Page Access Token
- Once your Page is linked to the app, the system will display an option to Generate Access Token.
- Click the Generate Token button next to the Page you selected.
- This token will be used to authenticate requests made to the Messenger API and to send/receive messages through the Facebook Page.
7. Set Permissions for the Access Token
- In the Complete App Review section, ensure you grant the necessary permissions for the access token. For basic Messenger functionality, permissions like pages_messaging and pages_show_list are typically required.
- You may also need to approve additional permissions depending on the functionality you wish to implement.
8. Configure Webhooks
- Set the Valid Callback URL and Verify Token:
- In the Facebook App Dashboard, navigate to Webhooks under your app settings.
- Enter the Callback URL for your Desk integration (e.g., https://your-desk-domain.com/webhook) in the Callback URL field.
- Enter a Verify Token of your choice. This token will be used to validate the webhook connection.
- Set the Callback URL and Verify Token in Output Desk:
- Before saving the Callback URL and Verify Token in the Facebook App Dashboard:
- Open the public folder in your Output Desk installation directory.
- Locate and open the client.js file using a text editor (e.g., Notepad or WordPad).
- Update the Verify Token:
In the client.js file, add the line as global.FaceBookVerifyToken and update it with the same token you plan to use in the Facebook App Dashboard. For example:global.FaceBookVerifyToken = "YOUR_DESIRED_PASSWORD";
- Restart Output Desk Services:
- Save the client.js file after making the changes.
- Restart the Output Desk services to apply the updated configurations.
- Finalize Callback URL and Verify Token in Facebook App:
- Return to the Webhooks section in your Facebook App Dashboard.
- Enter the Callback URL (e.g., https://your-desk-domain.com/webhook) and the Verify Token you set in the client.js file.
- Click Save to finalize the webhook configuration.
Step 2. Integrating the Access Token with Output Desk
1. Installing Facebook Plugin in Output Desk
- After successfully installing Output Desk as a service and verifying that it’s running in the browser, proceed to download the Facebook plugin code from facebook.zip.
- Extract the downloaded zip file.
- Go to the Output Desk package installation folder, create a folder named “plugins“, and navigate to that folder.
- Copy the Facebook folder into the “plugins” directory.
- After that, restart the Output Desk services.
2. Configuring Facebook Plugin in Output Desk
- Log in to Output Desk.
- Navigate to Settings > Channels > Facebook.
- Enter the following details:
- Access Token: Obtained from the Messenger API Settings.
- App ID: Your Facebook App ID.
- App Secret: Your Facebook App Secret.
- Save the configuration.
- Restart Output Desk services to apply the changes.
- Output Desk will now process incoming Facebook messages and send replies to Facebook.