Support multiple messages in the same request
I would like to send multiple messages to the bot service in the same request.
Yes, I'm waiting for it.
Just curious, what would you like to use this for @KstmSoft ?
@gfaraj, i want to use this for a Music Robot on Whatsapp. I would like when the user sends /music command send an message that notify him the music download and convert to mp3 process, and after that sends the audio. Hope you have an solution :+1:
If I understand correctly, you're looking to have the bot respond periodically with the progress of the conversion progress, then send the audio when it is done.
If that's so, the periodic progress messages can be implemented in the current version of the bot by using the callbackUrl property available in the incoming messages.
Take a look how I did the reminders or trivia plugins.
As for sending the resulting audio data, the Whatsapp client currently only supports images. You might need to upload it somewhere and send the link instead.
Yes, your solution works perfectly (in my case), I wrote an post call to callbackUrl sending the notification (same as reminders or trivia plugins do). I also implemented an simple function to do this more easier.
//target is the message parameter in bot.command
function notifyProcess(target, message){
let body = {
chat: { id: target.chat.id },
text: `*[🕗 ${message}]*`
};
axios.post(target.callbackUrl, body)
.then(async response => {
if (response.status == 200) {
console.log(`Received back: ${JSON.stringify(response.data)}`);
}
});
}
Thanks in advance, nice work!.
Yeah I should really add a nicer way to send a callback message, thanks for the suggestion. Glad it worked out for you!