wa-automate-nodejs
wa-automate-nodejs copied to clipboard
Session is not retrieved and sendLinkWithAutoPreview does not work
Are you using the latest version of the library?
- [X] I have checked and am using the latest version of the library.
What type of session are you experiencing this issue on?
Tested and experienced on both
What type of host account are you experiencing this issue on?
Personal account (normal)
Mode
My own code
Current Behavior
Yesterday I started using the library and everything worked fine with the session. Today when running the same code, without changes, again, the session is no longer being recovered. Every time I run the code, the QR code is printed and I have to authenticate again.
Also, the sendLinkWithAutoPreview method doesn't work, either on multiDevice=true or multiDevice=false.
Expected Behavior
No response
Steps To Reproduce
Just install the latest version and run the sample code from the readme.
create() code OR full CLI command + CONFIG
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: false,
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 => {
if (message.body === 'Hi') {
await client.sendText(message.from, '👋 Hello!');
}
});
}
DEBUG INFO
{
"WA_VERSION": "^4.43.1",
"WA_AUTOMATE_VERSION": "4.43.1",
"BROWSER_VERSION": "HeadlessChrome/103.0.5058.0",
"START_TS": 1659617960318,
"RAM_INFO": "Total: 16.91 GB | Free: 3.87 GB",
"PPTR_VERSION": "15.0.0",
"LATEST_VERSION": true,
"CLI": false
}
Environment
- OS: Windows 10
- Node: 18.7.0
- npm: 8.15.0
Screenshots/Logs
No response
Anything else?
No response
About the error on sendLinkWithAutoPreview
Debugging the code, I found that the problem happens when I don't pass the thumbnail parameter and the url has no image preview.
https://github.com/open-wa/wa-automate-nodejs/blob/master/src/api/Client.ts#L1754
My solution was pass a demo image to the thumbnail and it work.
@alexsanderluisdev please share the exact URL you are attempting to send
@alexsanderluisdev please share the exact URL you are attempting to send
https://checkout.juno.com.br/#/checkout/21220EB45E75B0C3970DE2B81EDA4EF989522873F4C7B179/oldLink
@alexsanderluisdev
I put your url in metatags.io and it shows that there's not many metatags there to extract

If this is your website please make sure you SSR the relevant metatags into the page upon first request and use metatags.io to make sure it looks right.
You can see in this project how the library attempts to get the metatags:
https://github.com/smashah/owa-meta-grabber
is there any way to send the link without preview? it doesn't make much sense to oblige to have the preview, not all links have
@alexsanderluisdev you can do that with sendText
.
I have updated the code to fallback to sendText
if the thumbnail is missing.
@github-actions run
⚡ Release! ⚡
(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`);
})();
Changelog
🚀 Release 4.43.4 (2022-08-14)
- ✨ ✨ ✨ ✨ DOCS V3 INIT ✨ ✨ ✨ ✨
d14df96
- Release 4.43.4
3fc8bfc
- 📝 update documentation
c0e5ccc
- 👔 update contact links
8394289
- 🩹 fallback to sendText if thumbnail is missing on
sendLinkWithAutoPreview
#2827b7b99ea
- 🙈 update .npmignore
c593c18
- 📝 update docs
79ee931
- 📝 update docs
b3b6b68
- 🥚 patches update
ed304bc
- 🥚 patches update
3f23fe1
- 🥚 patches update
a635c6d
- updated types-only package
d24b01b
- 🙈 update .gitigore
43b1f00
Now it should fallback to sendText