Trying to send a message to WhatsApp but getting error

โ€œAction Nameโ€: โ€œUrgent Team WhatsApp Notificationโ€,
โ€œErrorsโ€: โ€œError: The webhook url 'https://api.whatsapp.com/send?phone=SELECT(Users[WhatsApp],AND(IN(โ€œ10โ€,[GET_URGENT]), CONTAINS([Urgent_Method],{โ€œWhatsAppโ€}), [KEY_PRAYER]<>TRUE, IN([_THISROW].[TEAM_NO],[TEAM_NO]))) is not well formed Error: Failed to parse JSON due to Unexpected character encountered while parsing value: h. Path โ€˜โ€™, line 0, position 0โ€ฆโ€,
โ€œUrlโ€: โ€œhttps://api.whatsapp.com/send?phone=SELECT(Users[WhatsApp],AND(IN(โ€œ10โ€,[GET_URGENT]), CONTAINS([Urgent_Method],{โ€œWhatsAppโ€}), [KEY_PRAYER]<>TRUE, IN([_THISROW].[TEAM_NO],[TEAM_NO])))โ€,
โ€œVerbโ€: โ€œPostโ€,

I need the select statement to include only the records which fit the criteria.
questions: 1. can whatsapp process a list of numbers like an SMS workflow can?
2. How do I filter to get that list?

Iโ€™m sending the same notification, a link to a specific record in my app, via Email and Text and need to do the same for WhatsApp for international users since Text only works for U.S. and Canada.

Any help will be appreciated.

0 12 2,191
12 REPLIES 12

Steve
Platinum 5
Platinum 5

Maybe enclose the SELECT() expression in << and >>?

Thanks Steve, that got me closer. It passed the phone number on correctly

โ€œActionNotPerformedโ€: โ€œ1 errors present.โ€,
โ€œActionResultsโ€: โ€œCreated 1 ActionResultsโ€,
โ€œAction Typeโ€: โ€œWebhookโ€,
โ€œAction Nameโ€: โ€œUrgent Team WhatsApp Notificationโ€,
โ€œErrorsโ€: โ€œError: Failed to parse JSON due to Unexpected character encountered while parsing value: h. Path โ€˜โ€™, line 0, position 0โ€ฆโ€,
โ€œUrlโ€: "https://api.whatsapp.com/send?phone=1222333444,

The select appears to be putting a comma after the number, possibly since the result could easily be a list, but I think that is throwing the error.

I think the comma is an artifact of the error report format, not the output of your expression.

The result of a SELECT() expression is always a list, even if a list of just one item. If that comma has to do with the result of the SELECT() expression, it suggests there is more than one phone number, and that the second number is blank. Typically, though, the list of values produced by SELECT() would be separated by space-comma-space (,) rather than just comma (,).

Please post a screenshot of the error message, and a screenshot of the template.

Iโ€™m not using a template. Here is the full text of the URL field:
https://api.whatsapp.com/send?phone=<<SELECT(Users[WhatsApp#],AND(IN(โ€œ10โ€,[GET_URGENT]), CONTAINS([Urgent_Method],{โ€œWhatsAppโ€}), [KEY_PRAYER]<>TRUE, IN([_THISROW].[TEAM_NO],[TEAM_NO])))>>

Try this instead:

https://api.whatsapp.com/send?phone=<<ENCODEURL(SELECT(Users[WhatsApp#],AND(IN(โ€œ10โ€,[GET_URGENT]), CONTAINS([Urgent_Method],{โ€œWhatsAppโ€}), [KEY_PRAYER]<>TRUE, IN([_THISROW].[TEAM_NO],[TEAM_NO]))))>>

That got me a second phone number but still an error.

I suspect the Url line isnโ€™t the problem at this point, as it is valid. Instead, Iโ€™m concerned the Payload data does not appear to be JSON. Whatever the case, webhooks are outside my wheelhouse. Maybe @LeventK or @Aleksi might chime in?

Thanks for your help Steve. I appreciate it.

Firstly;
I believe rather than SELECT(), the expression shall be SUBSTITUTE((ANY(SELECT(...)),"+","") as phone parameter will only accept numbers. And as HTTP content is chosen as JSON, the payload body shall be:

{
    "text": "<<ENCODEURL([MessageColumnName])>>"
}

@Lucinda_Mason
@Steve
The main problem is this:
When you invoke this REST API, it automatically redirects you to a webpage to ensure that you have a WhatsApp account, so that you can send the text via WhatsApp web:


POSTMAN API CALL



JSFIDDLE FOR THE API CALL RESPONSE



CONCLUSION


Provided WhatsApp messaging is a must and you want to send those messages directly from an AppSheet App thru a webhook workflow, I might advise 2 options:
Option#1: Create your own Twilio Account and use their WhatsApp endpoint > https://www.twilio.com/whatsapp
Option#2: Create your own WhatsApp Business Account and then enroll for WhatsApp Business API > https://www.whatsapp.com/business/api/?lang=fb

Thanks Levent.

SO I changed a few things and got it to work, at least NO errors, but nothing opens in my browser and nothing comes through to my whatsapp app on my phone.

In other words, the webhook is running and working but wonโ€™t produce what I want unless I get either a twilio account or whatsapp business? Are those expensive?

here is what shows:
Response": "\n<html lang=โ€œenโ€ id=โ€œfacebookโ€ class=โ€œno_jsโ€>\n<meta charset=โ€œutf-8โ€ /><meta name=โ€œreferrerโ€ content=โ€œdefaultโ€ id=โ€œmeta_referrerโ€ /><script nonce=โ€œ14CLNRu1โ€>window._cstart=+new Date();<script nonce=โ€œ14CLNRu1โ€>function envFlush(a){function b(b){for(var c in a)b[c]=a[c]}window.requireLazy?window.requireLazy([โ€œEnvโ€],b):(window.Env=window.Env||{},b(window.Env))}envFlush({โ€œajaxpipe_tokenโ€:โ€œAXjfB20W-Rr18g8sEsYโ€,โ€œtimeslice_heartbeat_configโ€:{โ€œpollIntervalMsโ€:33,โ€œidleGapThresholdMsโ€:60,โ€œignoredTimesliceNamesโ€:{โ€œrequestAnimationFrameโ€:true,โ€œEvent listenHandler mousemoveโ€:true,"Event listenHandler
โ€ฆ
โ€œActionResultsโ€: โ€œCreated 1 ActionResultsโ€,
โ€œAction Typeโ€: โ€œWebhookโ€,
โ€œAction Nameโ€: โ€œUrgent Team WhatsApp Notificationโ€,
โ€œUrlโ€: โ€œhttps://api.whatsapp.com/send?phone=14072324214โ€,
โ€œVerbโ€: โ€œPostโ€,
โ€œMimeTypeโ€: โ€œapplication/jsonโ€,
โ€œHeadersโ€: โ€œโ€,
โ€œPayloadโ€: "{โ€œtextโ€: "https://tinyurl.com/y6rlyhks#appName=Requests-1778436&page=detail&rowc78f692f&table=Pri_Req_Visible_...,
โ€œAppTemplateNameโ€: โ€œ922dbed2-5196-4caa-9581-401fc815a472โ€,
โ€œOperationโ€: โ€œWorkflow actionโ€,
โ€œResultโ€: โ€œSuccessโ€

@Lucinda_Mason
You can review Twilio pricing from here > https://www.twilio.com/whatsapp/pricing/us