Twilio WhatsApp username - api

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?

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.

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

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.

Related

Bad Request on HTTP.Post with Discord Bot

Greetings and thank you for tending to this question!
I am trying to have my Discord bot create a Scheduled Guild Event.
A Calendar event for players and attendees to join a voice channel.
I am trying to achieve that by doing a POST call to Discord's API, and I am failing with the following error.
The following message was produced from a Postman test.
{
"code": 50109,
"message": "The request body contains invalid JSON."
}
As the message implies something is off with my JSON body.
Below follows a version of the JSON body I am trying to send!
{
"name": "The Bot created this!!!",
"privacy_level": 2,
"scheduled_start_time": "2022-06-15T15:00:00+00:00",
"description": "The Bot also described this!!",
"channel_id": 980830611458426901,
"entity_type": 2
}
I tried to follow the API's documentation as perfect as I could with no positive results!!
If you wish to follow the documentation yourselves here's the link:
Create Guild Scheduled Event
I am definitely missing something or adding something that should be added to the JSON body
of a different type!!! Any insights welcome!
What I know and tried
My authentication is solid because I am able to GET all events present.
Many variations of single quotes '' and type declarations for the data in the JSON body.
Regardless of insights, Thank you for your time!!

Viber API get all subscribers

I am trying to create a Viber Bot and looking for the method that can run through all subscribers I have in the specific Public account
I checked out all methods from Documentation but haven't found anything like "get_all_subscribers" or "get_all_users". So as far as I understood I have to set up callbacks for subscriptions. And to work around this data
{
"event": "subscribed",
"timestamp": 1457764197627,
"user": {
"id": "01234567890A=",
"name": "John McClane",
"avatar": "http://avatar.example.com",
"country": "UK",
"language": "en",
"api_version": 1
},
"message_token": 4912661846655238145
}
So am I missing some methods and it's possible or I should work around callbacks only?
According to viber documenation Viber API
We recommend that you record the subscriber ID of each subscriber, as there’s no API for fetching all subscriber IDs for your bot. You can find the subscriber ID in the sender.id property of the Message callback, or the user.id property of the Subscribed callback. You can see whether a user is subscribed in the subscribed parameter of the conversation_started callback. Note that users’ first message to the bot will make them subscribed, but will not result in a Subscribed callback.
You can get information about your subscribers using Get Account Info endpoint.
Its response contains subscribers_count and members (list with fields: id, name, avatar and role).
P.S. the only thing that you need to check is if the public account subscribers are chat bot subscribers too.

Webhook for hosted event?

I have a webhook subscribed to Page feed events.
I want it to tell me when a public event has been created on the page OR a page the user manages.
The app dashboard tells me this is the JSON object that will get sent to me:
{
"field": "feed",
"value": {
"item": "status",
"post_id": "44444444_444444444",
"verb": "add",
"published": 1,
"created_time": 1536110879,
"message": "Example post content.",
"from": {
"name": "Test Page",
"id": "1067280970047460"
}
}
}
Is the event id delivered in the post_id field?
If not, how is it passed to me?
How can I test this further?
Is my only choice to create events by hand, record the event id and fill it in as the returned post_id?
Can this webhook receive notification from multiple user's pages?
If so, how do I configure it to do so?
If not, how do I do something like that? Do I need multiple webhooks?
As per relevant webhooks doc reference https://developers.facebook.com/docs/graph-api/webhooks/reference/page/#feed
event_id is not delivered in the post_id.
event_id is passed inside value as event_id, you may need to check you app, seems like event_id is being filtered out in the response.
Testing it further is a broad query, although you could use curl to perform testing with the configured FB account.
In a more generic context, the above webhook response can be used to autogenerate/handle the post, that is the core purpose of the existence of the webhooks(to trigger and automate events as and when occurred).
No, this webhook is page specific.
You need to configure the webhook for each page separately. (Find the page_ids that can be used to work with other pages corresponding to the user)
The same webhook shall work, although the only difference shall be the page parameter, so you would have to configure another set of webhooks for each page, with a unique page_id related to that user account.
Note: Refer to https://developers.facebook.com/docs/graph-api/webhooks/getting-started for testing the webhooks.

Slack workspace bot to bot communication

i am trying to send messages through Amazon alexa via a bot-user to an already created chat bot that is within the workspace already.
after using webhooks i realised the chatbot does not recognize the messages i am posting through my bot-user.
my problem solving attempts included:
using the "as_user" method set as true. so messages are sent by the user but it seems to only visually change the name of the bot-user and my chat bot still does not respond to my messages.
is it even possible for a bot-user using slack web API to communicate to an App-bot that is within a channel on a workspace? I am using Postman to test. i suspect it has something to do with he scopes of the bot-user and the chatbot within the workspace just not being able to see the bot-user scope. This is all within the slack web api and this is how i am communicating with the workspace through the bot user.
see images to illustrate.
thanks alot hope you can help! :)
First image of postman:
second image of slack intentions:
Messages from real users look slightly different then message from bots / apps.
Apparently your chatbot is ignoring messages that are not coming form a real user. So the only way to "fix" that would be to modify the chatbot logic.
Example for message from real user:
{
"type": "message",
"user": "U12345467",
"text": "Good read for some of guys",
"ts": "1531745292.000021"
}
Example for a bot message:
{
"text": "Hey guys",
"bot_id": "B12345678",
"type": "message",
"subtype": "bot_message",
"ts": "1531700187.000049"
}

Verifying PayPal Mobile Payment - What to do with this verification

I'm using PayPal's new iOS SDK for a mobile app I'm doing. When a payment is processed, a verification of type: Adaptive Payments (when the user pays with PayPal) and
REST APIs (when the user pays with a credit card) are processed. My question is what am I suppose to do with these verifications. I've read their documentation but it isn't all that clear, obviously verifying helps with fraud, but I'm confused on the steps that are needed to handle these verifications. Do I send it to my server(php), if so what is my server suppose to do with it? Should I save these in the db? I'm new to PayPal if anyone could give some advice, I'd appreciate it thanks.
Example of Verification:
{
"proof_of_payment": {
"adaptive_payment": {
"pay_key": "AP-70M68096ML426802W",
"payment_exec_status": "COMPLETED",
"timestamp": "2013-02-20T00:26:25Z",
"app_id": "APP-91B933855X481767M"
}
},
"payment": {
"short_description": "Hipster t-shirt",
"amount": "9.95",
"currency_code": "USD"
},
"client": {
"platform": "iOS",
"paypal_sdk_version": "1.0.0",
"environment": "live",
"product_name": "PayPal iOS SDK"
}
}
You should send them to your server.
Your server (which you trust) should communicate directly with PayPal to verify that the proof of payments are valid. The documentation on verifying proofs of payment has details on what API calls you can make for verification. If you have specific questions about them, you should ask those separately, with details. The reason to verify them is that, if you don't, someone could give you a fake proof of payment and you wouldn't know it.
You probably want to save them in the db (or at the very least important chunks of them like the pay_key or payment_id).