Whatsapp API
I am trying to set up the Meta/Whatsapp API webhook and am completely lost.
Apparently, The Messenger Platform tries to "verify the webhook by sending a GET (instead of Post) request to the callback URL with certain parameters. Then the callback URL responds with the value of the hub.challenge parameter. The URL should validate that the hub.verify_token matches with the token that was entered in the app dashboard".
So, in Meta I enter the Xano endpoint:
and in Xano I have a standard webhook structure:
However, in Request history I receive nothing, and in Meta I get the error: "The URL couldn't be validated. Callback verification failed with the following errors: HTTP Status Code = 404; HTTP Message = Not Found
".
The strange thing is that if instead of a Xano endpoint, I enter a webhook.site url (The URL couldn't be validated. Response does not match challenge, expected value="1655664484", received=
".
I haven't worked with this structure of webhooks before and would appreciate any input.
Thanks.
Comments
-
Hello @techytech
Have you tried to change the Xano API to a GET instead of POST?
-
@Lefteris - buynocodeapps.com Yes, I tried but still the same issue.
EDIT: Actually, I changed it right now and published it (I had not done this before apparently) and now the error changed to "The URL couldn't be validated. Response does not match challenge, expected value="589033551", received="{\"hub_mode\":\"subsc..."
". -
@Lefteris - buynocodeapps.com Now, I just have to figure out how to validate the URL and I have no clue. Do you have any idea? Thanks.
-
@Chris Coleman @Michael Udinski @arturosanz any input on this would be appreciated. Thanks.
-
Hey @techytech,
Sorry for the delayed response.
First of all, can you provide us the full error you are getting back?
Secondly, could the api you are using require a redirect uri (that is not provided 2 in 1 with the Xano url)?
-
@Lefteris - buynocodeapps.com The error I get now is "
The URL couldn't be validated. Response does not match challenge, expected value="1424505902", received="{\"hub_mode\":\"subscri...
"Yeah, I think I have to return sth back one of the parameters but I do not know what because I do not understand the logic of this kind of webhook.
According to this topic, it is the hub.challenge value.
-
I think I found the problem.
You should somehow destructure what it receives.
Specifically you need to return the value of hub_challenge, yet you are sending a JSON with all the fields.
-
@Lefteris - buynocodeapps.com hmm how am I sending a JSON? I think I am returning nothing. How can return sth to the facebook api? should I add a new function after "get all input"? @Chris Coleman @Michael Udinski @arturosanz
-
@techytech the screenshot you uploaded says that you are sending back something and your response body is
{ "hub_mode": "subscribe", "hub_challenge": "1424505902", "hub_verify_token": "Token1" }
but it complains because your response should only be"1424505902"
.Remember to send it back as
hub..challenge
to bypass Xano's dot notation interpretation. -
@arturosanz thanks, now I think I got an idea how it should work. However, when return
payload.hub..challenge
I get the errorThe URL couldn't be validated. Callback verification failed with the following errors: HTTP Status Code = 500; HTTP Message = Internal Server Error
and in Xano I get :While if I set
payload.hub_challenge
I get the errorThe URL couldn't be validated. Response does not match challenge, expected value="684336876", received="\"684336876\""
while in Xano I get:So, I cannot seem to escape the dot nation as it says "Unable to locate var".
Am I doing sth wrong?
Thanks.
@Chris Coleman @Michael Udinski
-
Try these other options:
payload.hub\.challenge
payload get hub\.challenge
payload get hub%schallenge sprintf .
payload get hub_challenge replace _ .
An try adding
to_text
filter to the last 3 options as well (only to the hub challenge part) -
@arturosanz thanks for the reply. I tried all these combinations but none worked:
-
@Michael Udinski @Chris Coleman anyone has any input on this?
-
Hi @techytech - seems there is a lot to wrap my mind around here especially since it involves a 3rd party API. Are you able to come to office hours with the API documentation and walk-through ready? Someone from our team can help try to get you going in the right direction.
-
The solution was to add to_int to the variable. Thanks @Ray Deck!
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback