Reputation: 4417
I use Twilio [currently sandbox] for WhatsApp API.
I post to webhook when message is arrive to sandbox, I get data like this: {"SmsMessageSid":"xxxxxxxxxx","NumMedia":"0","SmsSid":"xxxxxxxxxx","SmsStatus":"received","Body":"try1","To":"whatsapp:+14xxxxxxxxxx","NumSegments":"1","MessageSid":"xxxxxxxxxx","AccountSid":"xxxxxxxxxx","From":"whatsapp:+97xxxxxxxxxx","ApiVersion":"2010-04-01"}
Is there a way to get the username?
Upvotes: 1
Views: 1329
Reputation: 179
WhatsApp Facebook API does have a name in the payload:
{
"contacts": [ {
"profile": {
"name": "Kerry Fisher"
},
"wa_id": "16315551234"
} ],
"messages":[{
"from": "16315551234",
"id": "ABGGFlA5FpafAgo6tHcNmNjXmuSf",
"timestamp": "1518694235",
"text": {
"body": "Hello this is an answer"
},
"type": "text"
}]
}
Source: https://developers.facebook.com/docs/whatsapp/api/webhooks/inbound
Talking to Twilio my team got the response bellow:
Twilio does not manage a user database. Although this is a data variable on the WhatsApp API, we are not leveraging it immediately as it is not mandatory from the WhatsApp docs and our data structure may not fully support this yet.
Again the Beta Nature of the Product will unveil product needs and features in which we have not moved forward with how or if we plan to support this.
There is at least one provider that I know that has this feature.
For me looks like Twilio recycled all the architecture they have for SMS without any regret of any drawbacks. We just found one, the absence of WhatsApp username in the message payload.
I reached Twilio asking for a deadline for this feature but until now I didn't receive any news yet.
Upvotes: 4
Reputation: 13
There is no username, all you will get is the number of the user that sent the message, which is the "From" value, unless the sender tells you its username through the message body.
Upvotes: -1
Reputation: 10771
The From is the WhatsApp username, do you mean how to programmatically extract the username (and if so, is there a particular language you are using)?
"From":"whatsapp:+97xxxxxxxxxx
Upvotes: 0