vonage-node-sdk icon indicating copy to clipboard operation
vonage-node-sdk copied to clipboard

How Do I: Create a WhatsApp template

Open acidfernando opened this issue 1 year ago • 2 comments

How do I

Create a WhatsApp template

API/Product

Messages

Code Sample

Hello!

I've been trying to send WhatsApp messages via /v1/messages endpoint, but it's throwing this error: "1340: Outside of Allowed Window"

From reading this I understand I need to create a template.

I could find only two resources that explain how to create a template. One of them is through jumper.ai's dashboard. I'm not sure how to go with this approach. I assume jumper.ai is not free, so I'd prefer not to go through with that option

The other way I found was through the API

I tried it and I could create a template with this payload:

{
   "name": "template_name",
   "language": "es",
   "category": "UTILITY",
   "allow_category_change": true,
   "components": [
      {
         "type": "BODY",
         "text": "example text for the issue"
      }
   ]
}

I then deleted because it had placeholder text. Then, I went to create a template with real data with this payload:

{
   "name": "upcoming_videoconsultations_administrator",
   "language": "es",
   "category": "UTILITY",
   "allow_category_change": true,
   "components": [
      {
         "type": "BODY",
         "text": "¡Buen día! Aquí tienes el resumen de tus videoconsultas de tu centro para mañana. Más detalles en {{1}}",
	"example": {
		      "body_text": "[['https://domain.com/path']]"
    	}
      }
   ]
}

This one fails with this error:

{
	"type": "https://developer.vonage.com/api-errors",
	"title": "Message template \"components\" param is missing expected field(s)",
	"detail": "component of type BODY is missing expected field(s) (example)",
	"instance": "uuid-v4-blabla-bla"
}

But I'm a little confused since I'm sending the example field just as the documentation says.

Am I doing something wrong?

Sorry in advance for posting this in vonage-node-sdk, I know it's not related to the sdk but I can't find another way of asking 🙏

acidfernando avatar Oct 02 '24 13:10 acidfernando

@acidfernando The SDK still needs to implement our WhatsApp template API. This is due to it being in beta. You can make calls by extending the Client in @vonage/server-client and then making the calls directly. Client will handle all the Auth when making requests.

I will leave this issue open to keep you updated as I get new information. It might be a while until we can get those endpoints implemented, so please keep checking back

manchuck avatar Oct 03 '24 09:10 manchuck

For the record, I ended up creating the templates directly on WhatsApp Business' Dashboard. This works well, I was able to then retrieve the created templates using Vonage's Template Beta endpoints and see their status, id, and etc.

I just wanted to leave that here just in case someone else stumbles with this thread 😛

acidfernando avatar Oct 10 '24 10:10 acidfernando