Creating a WhatsApp bot
Requirements Link to heading
- You will need a phone number that is not linked to WhatApp yet. “Your number must be used either on the Business Platform or on the Business App.” (source)
Steps Link to heading
- Create a Facebook account
- I didn’t have an Facebook account. I created a new one, but didn’t manage to use it to create a Meta Developer account. So, I had to create multiple accounts for one to work.
- Create a Meta Developer account
- Create a business portfolio
- Create a Facebook app
- Go to https://developers.facebook.com/apps/creation/
- Follow the steps. “Type” must be “Business” (and “Use cases” must be “Other”)
- Set up WhatsApp in your app
- Open your app - https://developers.facebook.com/apps/
- Look for WhatsApp under “Add products to your app”
- Click “Set up”
- Click “Start using the API”
- Adding your phone number
- Go to “Step 1: Select phone numbers” > “From”
- Click in the dropdown
- Click “Add phone number”
- Fill the fields and click next until you finish
- Save the “Phone number ID” for next steps. Use when you see
<PHONE_NUMBER_ID>
in this tutorial.
- Click “Generate access token”
- An pop up will open
- Click “Continue”
- Select “Opt in to current WhatsApp accounts only”
- Select your phone number
- Click “Continue”
- Click “Save”
- Save this token to the next steps. Use when you see
<ACCESS_TOKEN>
in this tutorial.
- Add Payment method
- Open https://business.facebook.com/billing_hub/accounts/details/
- Select your Business portfolio
- Go to “Payment methods”
- Add business payment method
- Set as payment method as default
- Repeat steps 1, 2, and 3
- Go to the “Payment methods” you added, settings (three dots) and click “Set as default”
- Set up Two-Step Verification (it will be required in the next step) (docs)
- Generate a 6-digit PIN (keep it safe). Use when you see
<PIN>
in this tutorial.
curl -X POST \ 'https://graph.facebook.com/v21.0/<PHONE_NUMBER_ID>' \ -H 'Authorization: Bearer <ACCESS_TOKEN>' \ -H 'Content-Type: application/json' \ -d '{"pin" : "<PIN>"}'
- Generate a 6-digit PIN (keep it safe). Use when you see
Optionals Link to heading
- Adding WhatsApp profile info
- Some info (like Profile photo) requires setting up the Two-Step Verification
- Go to https://business.facebook.com/latest/whatsapp_manager/phone_numbers/
- Select your WhatsApp account in the dropdown at the top right
- Click in your phone number
- Go to “Profile” and edit it.