ruby_whatsapp_sdk
ruby_whatsapp_sdk copied to clipboard
Add location header to templates
The API just released, adding the location to the template via headers:
API responses to template creation and editing requests now include the template's status and category.
Let me in @ignacio-chiazzo
Sure @Aaryanpal!
The template API code lives in the messages_api file.
Let me know if you need help. My DMs are open in TW https://twitter.com/ignaciochiazzo
@Aaryanpal have you had a chance to look at it?
Hey @ignacio-chiazzo
I see this issue has been stale for quite some time, and I'd like to take a peek. I'm still learning the ropes of the API and this codebase. So, to clarify a bit on the ask
Is this the approach you'd like to have when sending templates with location headers?
Let me know if I'm on the right track or missing something
location = WhatsappSdk::Resource::Location.new(
latitude: 25.779510,
longitude: -80.338631,
name: "My Miami Store",
address: "820 NW 87th Ave, Miami, FL"
)
location_parameter = WhatsappSdk::Resource::ParameterObject.new(type: "location", location: location)
location_component = WhatsappSdk::Resource::Component.new(
type: WhatsappSdk::Resource::Component::Type::Header,
parameters: [location_parameter]
)
messages_api.send_template(
sender_id: 123,
recipient_number: 123,
name: "location_test",
language: "en_US",
components: [location_component]
)
I haven't tried myself but the API says you need to specify the format: Location
official docs: https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/components#location-headers
Feel free to open a PR with the changes and a test case.
Yeah, when creating a template with a location header you must pass the `"format": "location"
However, you don't have to when sending a template—I'll open a PR, and we can continue the discussion there.
Here's the sending a template with location docs for reference