WhatsApp flow endpoint trigger

The WhatsApp flow endpoint trigger allows you to deploy an endpoint to power a dynamic WhatsApp flow using a no/low code approach. Using this trigger will provide:

  • No-Code Endpoint Deployment: Easily set up and configure your dynamic WhatsApp flow endpoint without any coding required. This simplifies the process of deploying an endpoint to manage and respond to incoming requests from a dynamic WhatsApp flows

  • Automatic Decryption and Encryption: The flow manages the decryption of incoming requests and the encryption of outgoing responses, ensuring secure communication. Simply provide your private key and passphrase during setup, and the system handles the rest.

  • Integration with Bird CRM Flow Actions: Leverage the full range of Bird CRM flow actions within your WhatsApp flows; for example getting contact information or making third party API requests.

Set up a WhatsApp Flow endpoint trigger

Generate RSA Key Pairs

WhatsApp Flows requires a public/private key pair to decrypt/encrypt data between WhatsApp and the flows endpoint. Firstly generate (or provide) the key pair.

You should keep the keys and passphrase safe for future reference.

# Replace '<your_passphrase>' with your actual passphrase
PASS="<your_passphrase>"

# Generate the private key with AES-256-CBC encryption and a passphrase
openssl genrsa -aes256 -traditional -passout pass:$PASS -out private_key.pem 2048

# Extract the public key from the private key
openssl rsa -pubout -in private_key.pem -out public_key.pem -passin pass:$PASS

Converting private key to add headers

It is important that your private key contains the following header information

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,AA3AC1C7DC568ACB8E3AC6790G40D9D1

To regenerate an existing private key to contain the headers you can run the following commands:

openssl rsa -in encrypted_key.pem -out decrypted_key.pem 
openssl rsa -in decrypted_key.pem -aes256 -traditional -passout pass:$PASS -out reencrypted_key.pem

Upload the public key

  1. Open public_key.pem in a text editor and copy its content.

  2. For each channel where you will send a dynamic WhatsApp flow navigate to Manage Channels > WhatsApp > WhatsApp Channel > Settings

  3. Paste the content into the "Public key" field.

  4. Click "Update" to save the public key

Configure WhatsApp flows trigger to use the private key

  1. Select WhatsApp flow endpoint as the trigger for your new Flow

  2. In the "Request Decryption and Encryption" section:

    • Private key: Open the private_key.pem file in a text editor, copy the entire content, and paste it into the "Private key" field.

    • Private key passphrase: Enter the passphrase you used when generating the private key into the "Private key passphrase" field.

  3. Click Next

Respond to health checks

WhatsApp will periodically invoke the flow and expect a certain response to confirm the endpoint is healthy

Add a conditional step

  1. Add a Conditional Step right after the WhatsApp Flow Endpoint trigger

Define Conditions:

  1. For Branch A, set a condition to check if the incoming request (trigger.payload.action) equals "ping".

  2. You can add more conditions or branches as needed for different types of incoming messages.

Set variables

  1. Add a Set Variables Step under the appropriate branch (e.g. Branch A).

  2. Configure the Variables:

    1. Use the Code Editor to define the variables. For example:

{
  "data": {
    "status": "active"
  },
  "version": "3.0"
}

Last updated