How to keep both button text and payload in whatsapp quick reply message template - whatsapp

Whatsapp quick reply request template has option for payload only. In what option we can configure the button text. After lots of searching on internet I did not find proper solution.
Here is the json of button which need to be send in request but it only has the payload option
{
"type": "button",
"sub_type" : "quick_reply",
"index": "0",
"parameters": [
{
"type": "payload",
# Business Developer-defined payload
"payload":"aGlzIHRoaXMgaXMgY29vZHNhc2phZHdpcXdlMGZoIGFTIEZISUQgV1FEV0RT"
}
]
},
Reference link: https://developers.facebook.com/docs/whatsapp/api/messages/message-templates/interactive-message-templates#request

You need to configure that in the Facebook Business Manager UI or in the Graph API post request when you create the template. When you're sending the message, you can't dynamically configure the text.

Related

Template message in whatsapp with static url

I am using whatsapp cloud api for messaging. I have created a template with a url button. In the template I have used a link to my app(Google play store). As per documentation,
https://developers.facebook.com/docs/whatsapp/on-premises/reference/messages#template-object
Developer provided suffix that will be appended to a previously created dynamic URL button.
I do not have any suffix as it is not a dynamic link. If I create a blank text parameter as sufix, Postman responds with error. How to create a url button without any suffix or please let me know if there is any other workaround for this issue. I do not want to add url directly into the body
{
"type": "button",
"sub_type": "url",
"index": "0",
"parameters": [
{
"type": "text",
"text": ""
}
]
}

What are these media providers in whatsapp apis?

I have setup a two way communication between business account and customer using whatsapp business apis. I am having trouble understanding media providers that there documentation talks about for sending text message to customer with image/media.
Heres the link to it: https://developers.facebook.com/docs/whatsapp/api/settings/media-providers/
Who are these providers? are they some specified organisation?
I am currently storing the media files in AWS S3 using some pre-signed url method. Can I use media stored in S3 in whatsapp media message?.
An example would be great help.
According to the Whatsapp API media messages documentation, there are two ways of sending an image outbound message:
Send the image by its Media ID
Send the image by its URL
When choosing 2, sending it by its URL, sometimes you may need to setup a Media Provider settings if the images URL you reference is not directly accessible and requires a username/password authentication or even a bearer token. (check https://developers.facebook.com/docs/whatsapp/api/messages).
Sending images by Media ID
To send it by ID, you need first to upload the image file using the POST /v1/media endpoint. That will return the Media-ID (e.g: 456) that you should use to compose the message object on the POST /v1/messages/ endpoint, like this:
{
"to": "1234567",
"type": "image",
"recipient_type": "individual",
"image": {
"caption": "The image caption",
"id": "456"
}
}
Sending images by URL
When sending it by URL, you can simply inform the URL of a image file (e.g.: http://yourcompany.com/images/your_image.png) on the link field of the POST /v1/messages/ endpoint, just like this:
{
"to": "1234567",
"type": "image",
"recipient_type": "individual",
"image": {
"caption": "The image caption",
"link": "http://yourcompany.com/images/your_image.png"
}
}
What if the URL http://yourcompany.com/images/your_image.png is behind some authentication on the server? (username/password ou maybe a bearer token). Then you need first to setup a Media Provider with such credentials, using the POST /v1/settings/application/media/providers endpoint, like this:
[{
"name": "yourcompany-images",
"type": "www",
"config": {
"basic": {
"username": "the-username",
"password": "the-password"
}
}
}
]
Once you have this set up on your API, then you are able to reference this Media Provider by its name on the POST /v1/messages/ endpoint, like this:
{
"to": "1234567",
"type": "image",
"recipient_type": "individual",
"image": {
"caption": "The image caption",
"link": "http://yourcompany.com/images/your_image.png"
"provider": {
"name" : "yourcompany-images"
}
}
}
Using S3 pre-signed URLs as image links
You have to consider that pre-signed URLs are temporary links that will expire after a while. It can work when everything is fine with you Whatsapp API Client and the message is promptly received by the recipient. But if something goes wrong on this chain, maybe the Whatsapp API will try to download the image again later. So keep this in mind and try to create pre-signed URLs with long expiration time (maybe a 7 day expiration link using IAM User as explained here).

How to send a message via url with inline buttons

I can send message, sample:
https://api.telegram.org/bot[TOKEN]/sendMessage?chat_id=#[USERNAME]&text=hello
but I want to send message with inline buttons, please help.
This would be the url you are looking for:
https://api.telegram.org/bot[TOKEN]/sendMessage?chat_id=[CHAT_ID]&text=[TEXT]&reply_markup={"inline_keyboard": [[{"text": "hi", "callback_data": "hi"}]]}
You can pass a JSON toreply_markup field. Here this our JSON:
{
"inline_keyboard": [
[
{
"text": "hi",
"callback_data": "hi"
}
]
]
}
I suggest you use an API library to communicate with Telegram. Using bare urls has its own challenges, like sometimes you should url encode your JSON to avoid errors in URL.
For example this is the url-encoded version of above JSON:
%7B%22inline_keyboard%22%3A%20%5B%5B%7B%22text%22%3A%20%22hi%22%2C%20%22callback_data%22%3A%20%22hi%22%7D%5D%5D%7D

How to know the Shopify username who triggered a webhook?

I have a product/update Shopify webhook. When the webhook event comes, I see the JSON payload but I don't get any clue about who updated the product. I need the username or email or whatever to identify the user who triggered the webhook. Is that even possible ? If yes, how ?
As per Shopify Documentation, product/update hook does not contain any information regarding the user who triggered the action. However, if it is extremely important for you to find out the user, a workaround is to use the Shopify Events API. As you already have the Product ID in the recieved webhook, you may issue another call to
GET /admin/products/#{product_id}/events.json
and in the response
{
"events": [
{
"id": 677313116,
"subject_id": 921728736,
"created_at": "2008-01-10T08:00:00-05:00",
"subject_type": "Product",
"verb": "create",
"arguments": [
"IPod Touch 8GB"
],
"body": null,
"message": "Product was created: IPod Touch 8GB.",
"author": "Shopify",
"description": "Product was created: IPod Touch 8GB.",
"path": "/admin/products/921728736"
}
]
}
you will have the author field. You may further filter the result using verb and created_at fields.
The supported events are
But I am also only able to get the created, published and unpublished events.

How to post event with metadata to stream through HTTP API

I'm using EventStore and want to post a message (event) to it. I use the HTTP API for testing purposes. I've managed to post the event itself, with an event type specified, but I can't figure out how to specify metadata for my event. (and I must provide this metadata because my consuming application on the other side expects it).
This is what my HTTP request looks like:
Content-Type: application/json
ES-EventType: My.own.event.type
POST http://10.0.75.2:2113/web/index.html#/streams/foobar
{
"props": "andvalues"
}
Do I specify metadata in the body in through headers? I can't find much docs about this, only the official that doesn't mention it.
The documentation mentions the full schema for an event being written. It looks like this:
[
{
"eventId" : "string",
"eventType" : "string",
"data" : "object",
"metadata" : "object"
}
]
For example:
[
{
"eventId": "fbf4a1a1-b4a3-4dfe-a01f-ec52c34e16e4",
"eventType": "event-type",
"data": { "a": "1" },
"metadata": { "b": "2" }
}
]
Note that it's an array, and that you must pass content-type as application/vnd.eventstore.events+json
Check this page, scroll to Event Store Events Media Type.