Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple messages in the same request #23

Open
gfaraj opened this issue Jan 21, 2020 · 6 comments
Open

Support multiple messages in the same request #23

gfaraj opened this issue Jan 21, 2020 · 6 comments

Comments

@gfaraj
Copy link
Owner

gfaraj commented Jan 21, 2020

I would like to send multiple messages to the bot service in the same request.

@KstmSoft
Copy link

KstmSoft commented Jan 21, 2020

Yes, I'm waiting for it.

@gfaraj
Copy link
Owner Author

gfaraj commented Jan 21, 2020

Just curious, what would you like to use this for @KstmSoft ?

@KstmSoft
Copy link

KstmSoft commented Jan 21, 2020

@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 👍

@gfaraj
Copy link
Owner Author

gfaraj commented Jan 22, 2020

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.

@KstmSoft
Copy link

KstmSoft commented Feb 17, 2020

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!.

@gfaraj
Copy link
Owner Author

gfaraj commented Feb 18, 2020

Yeah I should really add a nicer way to send a callback message, thanks for the suggestion. Glad it worked out for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants