feat: support additional WhatsApp API functions
This commit is contained in:
@@ -199,4 +199,106 @@ export default function registerWhatsappIntegration(server) {
|
||||
return { content: [{ type: "text", text: JSON.stringify(result) }] };
|
||||
}
|
||||
);
|
||||
|
||||
server.tool(
|
||||
"whatsapp.get-all-contacts",
|
||||
"Obtiene todos los contactos.",
|
||||
{},
|
||||
async () => {
|
||||
log("Tool invoked", "whatsapp.get-all-contacts");
|
||||
const result = await fetchJSON("/whatsapp/getAllContacts", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ args: {} }),
|
||||
});
|
||||
return { content: [{ type: "text", text: JSON.stringify(result) }] };
|
||||
}
|
||||
);
|
||||
|
||||
server.tool(
|
||||
"whatsapp.get-contact",
|
||||
"Obtiene la información de un contacto.",
|
||||
{
|
||||
contactId: z.string(),
|
||||
},
|
||||
async (params) => {
|
||||
log("Tool invoked", "whatsapp.get-contact", params);
|
||||
const result = await fetchJSON("/whatsapp/getContact", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ args: params }),
|
||||
});
|
||||
return { content: [{ type: "text", text: JSON.stringify(result) }] };
|
||||
}
|
||||
);
|
||||
|
||||
server.tool(
|
||||
"whatsapp.load-earlier-messages",
|
||||
"Carga mensajes antiguos hasta una fecha dada.",
|
||||
{
|
||||
contactId: z.string(),
|
||||
timestamp: z.number(),
|
||||
},
|
||||
async (params) => {
|
||||
log("Tool invoked", "whatsapp.load-earlier-messages", params);
|
||||
const result = await fetchJSON("/whatsapp/loadEarlierMessagesTillDate", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ args: params }),
|
||||
});
|
||||
return { content: [{ type: "text", text: JSON.stringify(result) }] };
|
||||
}
|
||||
);
|
||||
|
||||
server.tool(
|
||||
"whatsapp.react",
|
||||
"Reacciona a un mensaje.",
|
||||
{
|
||||
messageId: z.string(),
|
||||
emoji: z.string(),
|
||||
},
|
||||
async (params) => {
|
||||
log("Tool invoked", "whatsapp.react", params);
|
||||
const result = await fetchJSON("/whatsapp/react", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ args: params }),
|
||||
});
|
||||
return { content: [{ type: "text", text: JSON.stringify(result) }] };
|
||||
}
|
||||
);
|
||||
|
||||
server.tool(
|
||||
"whatsapp.reply",
|
||||
"Responde a un mensaje.",
|
||||
{
|
||||
to: z.string(),
|
||||
content: z.string(),
|
||||
quotedMsgId: z.string(),
|
||||
sendSeen: z.boolean().optional(),
|
||||
},
|
||||
async (params) => {
|
||||
log("Tool invoked", "whatsapp.reply", params);
|
||||
const result = await fetchJSON("/whatsapp/reply", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ args: params }),
|
||||
});
|
||||
return { content: [{ type: "text", text: JSON.stringify(result) }] };
|
||||
}
|
||||
);
|
||||
|
||||
server.tool(
|
||||
"whatsapp.send-text-with-mentions",
|
||||
"Envía un texto mencionando contactos.",
|
||||
{
|
||||
to: z.string(),
|
||||
content: z.string(),
|
||||
hideTags: z.boolean().optional(),
|
||||
mentions: z.array(z.string()).optional(),
|
||||
},
|
||||
async (params) => {
|
||||
log("Tool invoked", "whatsapp.send-text-with-mentions", params);
|
||||
const result = await fetchJSON("/whatsapp/sendTextWithMentions", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ args: params }),
|
||||
});
|
||||
return { content: [{ type: "text", text: JSON.stringify(result) }] };
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user