Issues with WhatsApp Cloud App Integration on Self-Hosted Instance

Hi everyone,

I’m looking for some help with two issues I’ve encountered while integrating the WhatsApp Cloud app with my self-hosted Rocket.Chat instance. Any guidance or advice would be greatly appreciated!

Issue 1: Agent Response Error

I’ve managed to automate the sending of template messages using the provided API . The messages are sent and received without any problems, and incoming messages show up correctly in the Rocket.Chat omnichannel.

The problem happens when I try to reply as an agent through the Rocket.Chat interface. I get the following error message:

Sorry! Couldn’t perform the operation since we’re experiencing some issues while connecting to WhatsApp.
Details:
Error Code: 500
Error Message: internal_server_error
Error Details: 131030: (#131030) Recipient phone number not in allowed list

This error occurs even though the recipient’s phone number is correctly registered in my Meta Developers dashboard.

Issue 2: Webhook Configuration for Message Status

In the WhatsApp Cloud app configuration tab, there’s a field to enter a URL endpoint to receive the status of exchanged messages. However, the documentation doesn’t specify if any particular response or action is required for the webhook. I’m assuming it just sends the status to the URL provided.

Questions:

  1. Has anyone else encountered the “Recipient phone number not in allowed list” error despite having the number registered in Meta Developers?
  2. Are there any extra steps or configurations I need to follow to enable agent responses through the Rocket.Chat interface?
  3. Regarding the webhook for message status, does the endpoint need to return any specific response for it to work properly?

Any help or insights would be greatly appreciated. These issues are currently limiting our ability to fully utilize the WhatsApp Cloud integration for our customer service operations.

Thanks in advance!

Can you fill out some basic server setup info as per this please:

Thanks.

Hello,

I’m sorry for the late reply. Here is the basic server setup information you requested:

  • Licence type: Starter
  • Number of users: Currently, we are still testing, so it is limited to 3 users.
  • Server hardware: VPS
  • Version of Rocket.Chat Server: 6.11.1
  • Operating System: Ubuntu
  • Deployment Method: Docker
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Primary
  • NodeJS Version: 14.21.3
  • MongoDB Version: 5.0.24

Client information:

  • Client type: Edge 127.0.2651.105

Steps to replicate the issue:

  1. Go to Administration > Apps > Marketplace.
  2. Search for the WhatsApp Cloud app.
  3. Click on Install and accept the necessary permissions.
  4. Create a chat with the WhatsApp-Cloud bot in the #omnichannel channel.
  5. Enter the required data to connect to the Facebook developer account and set up the Facebook developer webhook using the link and token provided by the WhatsApp-Cloud bot.
  6. Send a template using the POST API provided by WhatsApp-Cloud. In my case, I filled out the request body with the following information:
{
    "phoneNumbers": [
        "5255xxxxxxxx"
    ],
    "connectedWhatsAppNo": "357638614xxxxxx",
    "template": {
        "name": "appointment_confirmation",
        "language": {
            "code": "en_MX",
            "policy": "deterministic"
        },
        "components": [
            {
                "type": "body",
                "parameters": [
                    {
                        "type": "text",
                        "text": "Lorem ipsum dolor"
                    },
                    {
                        "type": "text",
                        "text": "sit amet, consectetur"
                    },
                    {
                        "type": "text",
                        "text": "adipiscing elit"
                    },
                    {
                        "type": "text",
                        "text": "Cras nibh mauris"
                    },
                    {
                        "type": "text",
                        "text": "malesuada sed enim"
                    }
                ]
            }
        ]
    }
}

Note: This is a custom template that I created in Facebook Developer, and it requires 5 parameters to be filled in.
7. You receive the template on your number (5255xxxxxxxx) and reply from that same number with a “Hello” message.
8. The “Hello” message is received in Rocket.Chat. Then, you reply from Rocket.Chat using the same user (administrator/agent/supervisor).
9. When sending the message from Rocket.Chat, the following error appears in the chat:

Sorry! Couldn't perform the operation since we're experiencing some issues while connecting to WhatsApp.
Details:
Error Code: 500
Error Message: internal_server_error
Error Details: 131030: (#131030) Recipient phone number not in allowed list.

I activated Rocket.Chat logs (level 2: errors, information, and debugging). When sending a message from Rocket.Chat, the following is recorded in the log:

{
    "level": 20,
    "time": "2024-08-23T17:37:47.634Z",
    "pid": 1,
    "hostname": "xxxxx",
    "name": "Integrations",
    "section": "Outgoing WebHook",
    "msg": "Got the event arguments for the event: sendMessage",
    "argObject": {
        "event": "sendMessage",
        "message": {
            "_id": "xxxxx",
            "rid": "xxxxxx",
            "msg": "Hello world",
            "ts": "2024-08-23T17:37:47.535Z",
            "u": {
                "_id": "xxxxx",
                "username": "xxxxx",
                "name": "xxxxx"
            },
            "_updatedAt": "2024-08-23T17:37:47.570Z",
            "urls": [],
            "mentions": [],
            "channels": [],
            "md": [
                {
                    "type": "PARAGRAPH",
                    "value": [
                        {
                            "type": "PLAIN_TEXT",
                            "value": "Hello world"
                        }
                    ]
                }
            ]
        },
        "room": {
            "_id": "xxxx",
            "cl": false,
            "estimatedWaitingTimeQueue": 9999999,
            "fname": "xxxxx",
            "lm": "2024-08-23T17:37:09.094Z",
            "msgs": 5,
            "open": true,
            "priorityWeight": 99,
            "queuedAt": "2024-08-23T17:36:46.237Z",
            "source": {
                "type": "app",
                "id": "xxxxx",
                "alias": "WhatsApp Cloud",
                "sidebarIcon": "whatsapp",
                "defaultIcon": "whatsapp",
                "label": "+1 555-6xx-xxxx"
            },
            "t": "l",
            "ts": "2024-08-23T17:36:46.237Z",
            "usersCount": 2,
            "v": {
                "_id": "xxxxx",
                "username": "52155xxxxxx",
                "token": "xxxxx",
                "status": "online",
                "activity": [
                    "2024-08"
                ],
                "lastMessageTs": "2024-08-23T17:36:57.293Z"
            },
            "_updatedAt": "2024-08-23T17:37:09.174Z",
            "lastMessage": {
                "_id": "xxxxx",
                "rid": "xxxx",
                "msg": "Hello world",
                "ts": "2024-08-23T17:37:09.094Z",
                "u": {
                    "_id": "xxxx",
                    "username": "xxxxx",
                    "name": "xxxxxx"
                },
                "_updatedAt": "2024-08-23T17:37:09.131Z",
                "urls": [],
                "mentions": [],
                "channels": [],
                "md": [
                    {
                        "type": "PARAGRAPH",
                        "value": [
                            {
                                "type": "PLAIN_TEXT",
                                "value": "Hello world"
                            }
                        ]
                    }
                ]
            },
            "metrics": {
                "v": {
                    "lq": "2024-08-23T17:36:46.261Z"
                },
                "reaction": {
                    "fd": "2024-08-23T17:37:09.174Z",
                    "ft": 22.937,
                    "tt": 22.937
                },
                "response": {
                    "avg": 22.913,
                    "fd": "2024-08-23T17:37:09.174Z",
                    "ft": 22.913,
                    "total": 1,
                    "tt": 22.913
                },
                "servedBy": {
                    "lr": "2024-08-23T17:37:09.094Z"
                }
            },
            "servedBy": {
                "_id": "xxxx",
                "username": "xxxxx"
            },
            "customFields": {
                "whatsAppCloudMessage": {
                    "visitorWaId": "xxxxxx",
                    "contactWaId": "xxxxxx"
                },
                "whatsAppCloudSessionExpiration": "2024-08-24T17:36:57.486Z"
            },
            "default": false,
            "ro": false,
            "sysMes": true,
            "responseBy": {
                "_id": "xxxxxx",
                "username": "xxxxx",
                "firstResponseTs": "2024-08-23T17:37:09.094Z",
                "lastMessageTs": "2024-08-23T17:37:09.094Z"
            }
        }
    }
}

I noticed that the phone number to which the message is being sent is logged as 52155xxxxxx, while the original number should be 5255xxxxxx. The extra ‘1’ in the middle is causing an error.

I attempted to correct this number in the Rocket.Chat Omnichannel Contact Center. However, the active chat with the contact still shows 52155xxxxxx as the phone number.

This discrepancy between the intended phone number and the one being used in the system is causing message delivery issues. I’m looking for guidance on how to properly update and sync the contact’s phone number across all relevant Rocket.Chat systems to ensure correct message routing.

Has anyone encountered a similar issue with phone number mismatches in Omnichannel, particularly when integrating with WhatsApp? Any insights on troubleshooting or resolving this would be greatly appreciated.

Please let me know if you need any more details. Thank you for your help!

HI,

I’ll try and get someone on the team to look at this.

Please be patient - they are busy people :slight_smile:

It might not be until later next week.

Thanks for getting back to me! I totally get that the team is busy, and I appreciate you passing the bug along to them.

In the meantime, I’m still stuck on the webhook setup for message statuses. I’m not sure if the endpoint needs to send a specific response or if there’s something else I’m missing.

If you or anyone else has any tips or ideas, that would be awesome!

There are no guarantees with open source.

That’s what paid support is for.

Did you test on the sandbox?

https://docs.rocket.chat/docs/whatsapp-sandbox