Closed Mizar-Contasti closed 1 year ago
To view the full error, try wrapping the sendText
in a try catch
, i.e:
bot.on("message", async (msg) => {
console.log(msg);
try {
if (msg.type === "text") {
await bot.sendText(msg.from, "Received your text message!");
} else if (msg.type === "image") {
await bot.sendText(msg.from, "Received your image!");
}
} catch (err) {
console.log(err);
}
});
@Mizar-Contasti, can I mark this as completed?
Hi Everyone, currently Im trying to receive "Received your text message!" that the bot sends when receives a message.
Right now I'm receiving start message when I start the server. But when trying to send the message, I got this output.
Right now My code is this ->
` const { createBot } = require('whatsapp-cloud-api');
(async () => { try { // replace the values below const from = ""; const token = ""; const to = ""; // const to = "524426581099"; const webhookVerifyToken = "";
} catch (err) { console.log(err); } })(); `