You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have this code it works when i want to send a template from a whatsapp number and have an application created in the dashboard:
require('dotenv').config({ path: '/Users/jaime/Documents/Bluu/templateFoto/.env' });
The problem is, How do i send this code without using the private key? I want to sent a template from the same number a whatsapp bot agent is running, and getting a new private key is going to kill the bot.
Once the vonage support via email told me i can get a JWT each time i want to send a message and i have this function:
async function obtenerJWTToken() {
try {
const response = await axios.get('https://studio-api-eu.ai.vonage.com/agents/65f31dbc22c0c4204fc065f2', {
headers: {
'X-Vgai-Key': '//MYKEYhere'
}
});
JWT_TOKEN = response.data.token;
console.log("Token actualizado: ", JWT_TOKEN);
} catch (error) {
console.error("Error al obtener el JWT Token: ", error);
}
}
But the thing here is how do i send the first code without the private key?
The text was updated successfully, but these errors were encountered:
I have this code it works when i want to send a template from a whatsapp number and have an application created in the dashboard:
require('dotenv').config({ path: '/Users/jaime/Documents/Bluu/templateFoto/.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: 'es_MX'
},
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));
The problem is, How do i send this code without using the private key? I want to sent a template from the same number a whatsapp bot agent is running, and getting a new private key is going to kill the bot.
Once the vonage support via email told me i can get a JWT each time i want to send a message and i have this function:
async function obtenerJWTToken() {
try {
const response = await axios.get('https://studio-api-eu.ai.vonage.com/agents/65f31dbc22c0c4204fc065f2', {
headers: {
'X-Vgai-Key': '//MYKEYhere'
}
});
JWT_TOKEN = response.data.token;
console.log("Token actualizado: ", JWT_TOKEN);
} catch (error) {
console.error("Error al obtener el JWT Token: ", error);
}
}
But the thing here is how do i send the first code without the private key?
The text was updated successfully, but these errors were encountered: