We are currently in the process of implementing the Whatsapp Embedded Signup fucntionality that will be required by Twilio later in the year.
We've followed the documentation and we think we haven't made any mistakes.
In our front-end, everything works fine. The correct Whatsapp Business Account ID and Phone Number ID are retrieved from the Meta window.
After this we attempt to register these credentials to a new subaccount in Twilio using Twilio's Java library. We retrieve the phone number to use as the sender using Meta's API.
The step that fails is registering a Whatsapp Sender on the Twilio subaccount. This is done the following way:
private LinkedPhoneNumberResponseDto linkTwilioPhoneNumber(String countryCode, String phoneNumber, Account account, Long wabaId) {
TwilioCreateRequestDto body = TwilioCreateRequestDto.builder()
.configuration(WhatsappTwilioConnectionConfigurationRequestDto.builder()
.wabaId(wabaId.toString())
.build())
.senderId("whatsapp:" + countryCode + phoneNumber)
.profile(WhatsappTwilioConnectionProfileRequestDto.builder()
.name(account.getFriendlyName())
.build())
.build();
log.info("RequestBody is: {}", body);
log.info("ACC INFO = {}:{}:{}:{}", account.getSid(), account.getAuthToken(), account.getFriendlyName(), account.getStatus());
ResponseEntity<LinkedPhoneNumberResponseDto> res = restClient
.post()
.uri("https://messaging.twilio.com/v2/Channels/Senders")
.headers(headers -> {
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setBasicAuth(account.getSid(), account.getAuthToken());
})
.body(body)
.accept(MediaType.ALL)
.retrieve()
.toEntity(LinkedPhoneNumberResponseDto.class);
if (res.getStatusCode().is2xxSuccessful()) {
return res.getBody();
} else {
throw new BadRequestException("Something went wrong linking the phone number to Twilio");
}
}
For some reason, no matter what phone number we use, we always get the validation error.
We've already tried making the request thorugh Postman instead of Twilio's Java library. We've also tried three different phone numbers. Multiple Whatsapp Business Accounts have also been used.
Any help would be appreciated.