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

  1. 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.
  2. Create a Meta Developer account
  3. Create a business portfolio
  4. Create a Facebook app
    1. Go to https://developers.facebook.com/apps/creation/
    2. Follow the steps. “Type” must be “Business” (and “Use cases” must be “Other”)
  5. Set up WhatsApp in your app
    1. Open your app - https://developers.facebook.com/apps/
    2. Look for WhatsApp under “Add products to your app”
    3. Click “Set up”
    4. Click “Start using the API”
    5. Adding your phone number
      1. Go to “Step 1: Select phone numbers” > “From”
      2. Click in the dropdown
      3. Click “Add phone number”
      4. Fill the fields and click next until you finish
      5. Save the “Phone number ID” for next steps. Use when you see <PHONE_NUMBER_ID> in this tutorial.
    6. Click “Generate access token”
      1. An pop up will open
      2. Click “Continue”
      3. Select “Opt in to current WhatsApp accounts only”
      4. Select your phone number
      5. Click “Continue”
      6. Click “Save”
      7. Save this token to the next steps. Use when you see <ACCESS_TOKEN> in this tutorial.
  6. Add Payment method
    1. Open https://business.facebook.com/billing_hub/accounts/details/
    2. Select your Business portfolio
    3. Go to “Payment methods”
    4. Add business payment method
    5. Set as payment method as default
      1. Repeat steps 1, 2, and 3
      2. Go to the “Payment methods” you added, settings (three dots) and click “Set as default”
  7. Set up Two-Step Verification (it will be required in the next step) (docs)
    1. 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>"}'
    

Optionals Link to heading