|
|
|
@ -14,13 +14,10 @@ if (!API_URL || !INSTANCE_NAME || !API_KEY) {
|
|
|
|
|
// Send a message with optional mentions
|
|
|
|
|
export async function sendMessage(phone: string, message: string, mentions: string[] = []) {
|
|
|
|
|
try {
|
|
|
|
|
const payload: any = {
|
|
|
|
|
number: phone,
|
|
|
|
|
text: message,
|
|
|
|
|
};
|
|
|
|
|
let payload: any;
|
|
|
|
|
|
|
|
|
|
// Add mentions if provided
|
|
|
|
|
if (mentions.length > 0) {
|
|
|
|
|
// Format with mentions
|
|
|
|
|
payload = {
|
|
|
|
|
number: phone,
|
|
|
|
|
options: {
|
|
|
|
@ -36,6 +33,12 @@ export async function sendMessage(phone: string, message: string, mentions: stri
|
|
|
|
|
text: message
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
// Simple message format
|
|
|
|
|
payload = {
|
|
|
|
|
number: phone,
|
|
|
|
|
text: message
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await axios.post(`${API_URL}/message/sendText/${INSTANCE_NAME}`, payload, {
|
|
|
|
|