# WhatsApp flow endpoint trigger

The WhatsApp flow endpoint trigger allows you to deploy an endpoint to power a dynamic [WhatsApp flow](/applications/channels/channels/supported-channels/whatsapp/how-to/create-a-whatsapp-flow.md) using a no/low code approach. Using this trigger will provide:&#x20;

* **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.&#x20;

{% hint style="info" %}
You should keep the keys and passphrase safe for future reference.
{% endhint %}

```bash
# 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:

{% code overflow="wrap" %}

```bash
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
```

{% endcode %}

### Upload the public key

1. Open `public_key.pem` in a text editor and copy its content.
2. Navigate to **Settings** from the bottom-left corner, then go to **Connectivity** under **Workspace.** From the dropdown, select **Channels**, choose WhatsApp, open each channel where you will send a dynamic WhatsApp flow, and click the **Settings** button in the top-right corner.

<figure><img src="/files/5cL75a70NLS7HEl5TwXX" alt="" width="375"><figcaption></figcaption></figure>

<figure><img src="/files/mExAm8Bd8bhhvAscdCkt" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/PkDvh6HZqJirZ51aXMZc" alt=""><figcaption></figcaption></figure>

3. Paste the content into the "Public key" field.\
   ![](/files/NyRGC8q6JwPdikIRUmUR)
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\
   ![](/files/ANCt3HS9Z9gbR88gce8z)
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

{% hint style="info" %}
WhatsApp will periodically invoke the flow and expect a certain response to confirm the endpoint is healthy
{% endhint %}

#### Add a conditional step

1. **Add a Conditional Step** right after the WhatsApp Flow Endpoint trigger\
   ![](/files/UJ48x3bxv17n9EDvOzBL)

**Define Conditions**:

1. For Branch A, set a condition to check if the incoming request (`trigger.payload.action`) equals "ping".\
   ![](/files/YZM4PYacQialZoMNsuUB)
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:\
      ![](/files/FyA6WCMwKMUAh5xtSBfT)

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bird.com/applications/automation/flows/concepts/triggers/whatsapp-flow-endpoint-trigger.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
