How Do I: Send this template
JaimeCasillasBluu opened this issue · 4 comments
How do I
Im trying to send this whatsapp template from a whatsapp number, but i only get the response ok UUID, but i dont receive the message this is the response: Response: { "messageUUID": "26e2b312-ce37-461d-9989-854b6e2b2ce6" } Message UUID: 26e2b312-ce37-461d-9989-854b6e2b2ce6
API/Product
Messages
Code Sample
require('dotenv').config({ path: __dirname + '/../../.env' });
const VONAGE_API_KEY = process.env.VONAGE_API_KEY;
const VONAGE_API_SECRET = process.env.VONAGE_API_SECRET;
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID;
const VONAGE_PRIVATE_KEY = process.env.VONAGE_PRIVATE_KEY;
const TO_NUMBER = process.env.TO_NUMBER;
const WHATSAPP_NUMBER = process.env.WHATSAPP_NUMBER;
const WHATSAPP_TEMPLATE_NAME = process.env.WHATSAPP_TEMPLATE_NAME;
const IMAGE_URL = process.env.IMAGE_URL;
const WHATSAPP_TEMPLATE_REPLACEMENT_TEXT = process.env.WHATSAPP_TEMPLATE_REPLACEMENT_TEXT;
const { Vonage } = require('@vonage/server-sdk');
const { WhatsAppCustom } = require('@vonage/messages');
const vonage = new Vonage({
apiKey: VONAGE_API_KEY,
apiSecret: VONAGE_API_SECRET,
applicationId: VONAGE_APPLICATION_ID,
privateKey: VONAGE_PRIVATE_KEY,
});
vonage.messages.send(
new WhatsAppCustom({
custom: {
type: 'template',
template: {
name: ${WHATSAPP_TEMPLATE_NAME}
,
language: {
policy: 'deterministic',
code: 'en'
},
components: [
{
type: 'header',
parameters: [
{
type: 'image',
image: {
link: ${IMAGE_URL}
}
}
]
},
{
type: 'body',
parameters: [
{
type: 'text',
text: ${WHATSAPP_TEMPLATE_REPLACEMENT_TEXT}
}
]
}
]
}
},
to: TO_NUMBER,
from: WHATSAPP_NUMBER,
}),
)
.then(resp => console.log(resp.message_uuid))
.catch(err => console.error(err));
@JaimeCasillasBluu, You sent the message through the API correctly. And yes, you will only get back the message's UUID. After we receive the message through the API, we will send it to the appropriate channel. Since that can take some time, the messages API will only return the UUID.
You can take this UUID and check the messaging logs either in your developer dashboard or through the reports API. Keep in mind that it can take up to 15 minutes to get back any status on a message. In the dashboard, we break down each step as a line item so you can see where it failed and go from there.
Another option is to check and see what statuses come through in the webhook you configured for the application. You will get a post for each time the status changes
If you can get the error message out, I could provide more information or point you to the correct place to troubleshoot the issue
Ok, I was able to send the message and receive it. But I have this other doubt. I want to send this template from a bot that is in AI Studio, to send the vonage object I need the private key, but when I get the private key from the AI Studio bot application this is deactivated, how can I send a template and the message comes out of the same number and using the same AI STUDIO bot application?
@JaimeCasillasBluu, yes, that is what I brought up to the AI studio team. Currently, there is no way to get the private key from the AI studio application. Until that is addressed, you will not be able to use the same application that AI studio uses. I will check with the team this week to find out what they purpose the solution for this would be
Hey @JaimeCasillasBluu can you raise a ticket with the Studio team and describe your Issue (You can link to this page to do the heavy lifting), then the Studio team will be able to get directly in touch with you and move forward.
Thanks!