Before starting, ensure you have a Facebook Page. If you don't have one, create a Facebook Page first.
-
Navigate to Facebook Developers:
- Open your web browser and go to developers.facebook.com.
-
Create a Developer Account (if you don’t have one):
- If you’re new to Facebook Developers, log in with your Facebook credentials and follow the prompts to set up a developer account.
- Create an App:
- Click on "My Apps" in the top-right corner.
- Select "Create App".
- Choose "Business" as the type of app.
- Fill out the required details such as the app display name and contact email, then click "Create App ID".
- Add Messenger:
- In the left sidebar of your app's dashboard, click on "Add Product".
- Find "Messenger" and click on the "Set Up" button next to it.
- Generate a Page Access Token:
- Scroll down to the "Access Tokens" section.
- Click on "Add or Remove Pages".
- Follow the prompts to connect your Facebook Page.
- Once connected, generate a Page Access Token by clicking "Generate Token". Copy this token for later use.
- Configure Webhooks:
- In the Messenger settings, scroll to the "Webhooks" section.
- Click on "Setup Webhooks".
- Enter the following details:
- Callback URL:
https://your_hosting.site/webhook
- Verify Token:
123456
- Callback URL:
- Subscribe to the following fields:
messages
messaging_optins
messaging_postbacks
- Click "Verify and Save".
- Subscribe to Page Events:
- Still in the Webhooks section, under "Page Subscriptions", select the page you connected earlier.
- Ensure that
messages
,messaging_optins
, andmessaging_postbacks
are selected for this subscription.
- Retrieve Token:
- Go back to the "Access Tokens" section.
- Copy the generated Page Access Token.
- Configure Bot with Token:
- Paste the Page Access Token into
token.txt
.
- Paste the Page Access Token into
- Test Bot Functionality:
- Open your connected Facebook Page.
- Send a message to your page from a different Facebook account or just send "help" to check available commands.
- Make sure that the account you will use to test the bot has a role in the app.
- The bot will only respond to accounts that have specific roles assigned within the app.
-
Navigate to developers.facebook.com:
- Open your web browser and go to developers.facebook.com.
-
Access Your App:
- Log in to your Facebook Developer account.
- Navigate to the dashboard or "My Apps" section to find your app.
-
Select "App Roles":
- Once you've accessed your app's dashboard, look for a section or tab labeled "App Roles" or "Roles and Permissions".
-
Add Roles:
- Within the "App Roles" section, you should see options to add or manage roles.
- Click on the "Add Role" or similar button to start adding roles.
-
Define Role Details:
- Specify the name and permissions associated with the new role you want to add. You can create custom roles tailored to your app's requirements.
-
Assign Roles to Users:
- After defining the role, you can assign it to specific users associated with your app. You may need to provide the user's name or user ID to assign the role.
- This tutprial is made by Adrian (Fyi, i dunno him)