WhatsApp Flows Endpoint Health Check Error

123 views Asked by At

I am getting the error below when I am trying to publish my flow.

enter image description here

Here is a snippet of my endpoint, it's afirebase cloud function

exports.webhook = functions.https.onRequest( (request,response)=>{

    const body = request.body;
    const { decryptedBody, aesKeyBuffer, initialVectorBuffer } = decryptRequest(
        body
      );
    
      const { screen, data, version, action } = decryptedBody;
      
     if (action === "ping") {
        const res =  `{
            "version": "3.0",
            "data": {
                "status": "active"
            }
        }`
        response.send(res)
        }

})

2

There are 2 answers

0
Arjun Nemani On BEST ANSWER

As per the Encrypted Secure Data Channel Docs for WhatsApp Flows.


After processing the decrypted request, create a response (which must be encrypted) before sending it back to the WhatsApp client. Encrypt the payload using the AES key received in the request according to the rules specified below and send it back as a Base64 string. You can reference an example of how to encrypt the response here.


Please make sure that you are encrypting the response, as it is not obvious from the code snippet if this is being done.

Thanks for using WhatsApp Flows, and please reach out if you still face problems :)

0
David  Kathoh On

exports.webhook = functions.https.onRequest( (request,response)=>{

    const body = request.body;
    const { decryptedBody, aesKeyBuffer, initialVectorBuffer } = decryptRequest(
        body
      );
    
      const { screen, data, version, action } = decryptedBody;
      
     if (action === "ping") {
        const res =  {
            "version": "3.0",
            "data": {
                "status": "active"
            }
        }
        response.send(encryptResponse(res,aesKeyBuffer,initialVectorBuffer))
        }

})