open-wa / wa-automate-nodejs

πŸ’¬ πŸ€– The most reliable tool for chatbots with advanced features. Be sure to 🌟 this repository for updates!
https://docs.openwa.dev/
Other
3.15k stars 600 forks source link

feat [MD]: URL & Call buttons #2394

Closed smashah closed 2 years ago

smashah commented 2 years ago

It's time

98

smashah commented 2 years ago

URL, Call + standard button example

await client.B(chatId, {
    "templateMessage": {
        "hydratedTemplate": {
            "hydratedButtons": [
                {
                    "index": 1,
                    "urlButton": {
                        "displayText": "I am a link",
                        "url": "https://github.com/open-wa/wa-automate-nodejs"
                    }
                },
                {
                    "index": 2,
                    "callButton": {
                        "displayText": "Call me now!",
                        "phoneNumber": "+1234567890"
                    }
                },
                {
                    "index": 3,
                    "quickReplyButton": {
                        "displayText": "Or just click me",
                        "id": "button-1"
                    }
                }
            ],
            "hydratedContentText": "content",
            "hydratedFooterText": "footerer"
        }
    }
});

CleanShot 2022-04-11 at 08 55 29@2x

smashah commented 2 years ago

@github-actions run

⚑ Release! ⚑ ```js (async () => { function exec(cmd) { console.log(execSync(cmd).toString()); } //set the version type process.env.VERS = "patch" // Config const gitUserEmail = "github-actions[bot]@users.noreply.github.com"; const gitUserName = "github-actions[bot]"; exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`); exec(`git config --global user.email "${gitUserEmail}"`); exec(`git config --global user.name "${gitUserName}"`); exec(`npm i -D`); exec(`npm run release-ci $VERS`); // types only package exec('npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN') exec(`cd ./types-only && npm version $VERS && npm run build && npm publish && cd ..`); exec(`git commit -a -m 'updated types-only package'`); exec(`git push --force`); //comment on the issue var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString(); await postComment(result); //create changelog image exec(`npm run release-image`); exec(`git commit -a -m 'updated release-image'`); exec(`git push --force`); })(); ```
smashah commented 2 years ago

Changelog

πŸš€ Release 4.35.5 (2022-04-14)

smashah commented 2 years ago

@github-actions run

⚑ Release! ⚑ ```js (async () => { function exec(cmd) { console.log(execSync(cmd).toString()); } //set the version type process.env.VERS = "patch" // Config const gitUserEmail = "github-actions[bot]@users.noreply.github.com"; const gitUserName = "github-actions[bot]"; exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`); exec(`git config --global user.email "${gitUserEmail}"`); exec(`git config --global user.name "${gitUserName}"`); exec(`npm i -D`); exec(`npm run release-ci $VERS`); // types only package exec('npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN') exec(`cd ./types-only && npm version $VERS && npm run build && npm publish && cd ..`); exec(`git commit -a -m 'updated types-only package'`); exec(`git push --force`); //comment on the issue var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString(); await postComment(result); //create changelog image exec(`npm run release-image`); exec(`git commit -a -m 'updated release-image'`); exec(`git push --force`); })(); ```
smashah commented 2 years ago

Changelog

πŸš€ Release 4.35.6 (2022-04-14)

idham commented 2 years ago

can you give us example for easy API request JSON format?

smashah commented 2 years ago

can you give us example for easy API request JSON format?

https://github.com/open-wa/wa-automate-nodejs/discussions/2669

idham commented 2 years ago

can you give us example for easy API request JSON format?

2669

Thank you so much

idham commented 2 years ago

can you give us example for easy API request JSON format?

2669

why is it returning error, is there and update ?

{ "success": false, "error": { "name": "Error", "message": "Evaluation failed: TypeError: _0x8e9447_0x3ab137(...) is not a function\n at eval (eval at (:1:10), :1:86675)\n at Array.map ()\n at eval (eval at (:1:10), :1:86557)" } }

smashah commented 2 years ago

Can't tell why you're getting that error unless you share code and context

idham commented 2 years ago

sorry for missing the context

a day before I was testing https://github.com/open-wa/wa-automate-nodejs/issues/2394#issuecomment-1128937794 using Postman for Baileys endpoint .. and it works, in the morning all the payload are returning error

and then I was trying the sendButtons endpoint using last known works example { "args": { "to": "62811229454@c.us", "body": { "caption": "Paskal Roadshow Jakarta", "lat": -6.2, "lng": 106.8 }, "buttons": [ {"id":"1","text":"Registrasi"}, {"id":"2","text":"FAQ"}, {"id":"1","text":"Term of Service"} ], "title": "Welcome Message", "footer": "Paskal Indonesia" } }

and give return error as {"success":false,"error":{"name":"Error","message":"Evaluation failed: TypeError: _0x21a700_0x581b93(...) is not a function\n at eval (eval at (:1:10), :1:107964)\n at Array.map ()\n at eval (eval at (:1:10), :1:107849)"}}

I just used the npx easy API and didn't change anything

smashah commented 2 years ago

@github-actions run

⚑ Release! ⚑ ```js (async () => { function exec(cmd) { console.log(execSync(cmd).toString()); } //set the version type process.env.VERS = "minor" // Config const gitUserEmail = "github-actions[bot]@users.noreply.github.com"; const gitUserName = "github-actions[bot]"; exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`); exec(`git config --global user.email "${gitUserEmail}"`); exec(`git config --global user.name "${gitUserName}"`); exec(`npm i -D`); exec(`npm run release-ci $VERS`); // types only package exec('npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN') exec(`cd ./types-only && npm version $VERS && npm run build && npm publish && cd ..`); exec(`git commit -a -m 'updated types-only package'`); exec(`git push --force`); //comment on the issue var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString(); await postComment(result); //create changelog image exec(`npm run release-image`); exec(`git commit -a -m 'updated release-image'`); exec(`git push --force`); })(); ```
smashah commented 2 years ago

Changelog

πŸš€ Release 4.39.0 (2022-06-12)

smashah commented 2 years ago

@idham please try again and see https://github.com/open-wa/wa-automate-nodejs/discussions/2669 for how to use advanced buttons

idham commented 2 years ago

thx @smashah for the update, I didn't change anything and it works now

dafner commented 2 years ago

I'm new to using this library and I'm testing how button submission works for an application I'm developing.

With the code used for the test it has been impossible for me to send the buttons.

Is there any problem or limitation that prevents the correct operation of sending buttons?

I would appreciate any kind of help to be able to send buttons with the sendButtons function

Thank you

const wa = require('@open-wa/wa-automate');

wa.create({ sessionId: "COVID_HELPER", multiDevice: true, //required to enable multiDevice support authTimeout: 60, //wait only 60 seconds to get a connection with the host account device blockCrashLogs: true, disableSpins: true, headless: true, hostNotificationLang: 'PT_BR', logConsole: true, popup: true, qrTimeout: 0, //0 means it will wait forever for you to scan the qr code }).then(client => start(client));

function start(client) { client.onMessage(async message => { console.log(message);

if (message.body === 'Hi') {
  await client.sendText(message.from, 'πŸ‘‹ Hello!');
}

if (message.body === 'Buttons') {
    await client.sendButtons(message.from, "Body", [
        {
            id: "1",
            "text": "Click"
        },
        {
            id: "1",
            "text": "Call"
        },
        {
            id: "1",
            "text": "Open Link"
        }
    ], "title", "footer");
}

}); }

smashah commented 2 years ago

@dafner buttons on MD requires a license πŸ‘

dafner commented 2 years ago

Thanks for your prompt answer!

I have a cuestion, I probed other libraries from github and it's imposible to send buttons due a limitation of WA Business MultiDevice

If I purchase a license, you can assure me that I could send buttons and List without problems?

Wich kind of licence I must be purchase ? A Restricted License Key or insiders Programs?

I must purchase one licence for every number that I used in my development?

Thanks

El 22/06/2022 a las 10:38 p.Β m., Mohammed Shah escribiΓ³:

@dafner https://github.com/dafner buttons on MD requires a license πŸ‘

β€” Reply to this email directly, view it on GitHub https://github.com/open-wa/wa-automate-nodejs/issues/2394#issuecomment-1163829011, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACR6454B5VBPYPFC2PVLQLLVQO5YJANCNFSM5LCZY27Q. You are receiving this because you were mentioned.Message ID: @.***>

smashah commented 2 years ago

@dafner Insiders gives you access to buttons, Restricted will allow you to start conversations with non-contacts.

I just tested - list buttons are working with MD business accounts.

Yes 1 licenses is linked to just 1 host account. If you need more than 5 please email me: shah@openwa.dev

smashah commented 2 years ago

Buttons will not be GA for the foreseeable future. It looks like they will be restricting usage of buttons to verified business accounts only anyways soon.