Wa-automate-nodejs: ERROR SendText new contact

Created on 29 Apr 2020  Â·  5Comments  Â·  Source: open-wa/wa-automate-nodejs

I try send a msg to a new contact and the console show this
(node:1883) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: chat.sendMessage is not a function
at Object.window.WAPI.sendMessage (/home/daniel/node_modules/@open-wa/wa-automate/dist/lib/wapi.js:857:31)
at ExecutionContext._evaluateInternal (/home/daniel/node_modules/puppeteer/lib/ExecutionContext.js:93:19)
at process._tickCallback (internal/process/next_tick.js:68:7)
-- ASYNC --
at ExecutionContext. (/home/daniel/node_modules/puppeteer/lib/helper.js:83:19)
at DOMWorld.evaluate (/home/daniel/node_modules/puppeteer/lib/DOMWorld.js:111:24)
at process._tickCallback (internal/process/next_tick.js:68:7)
-- ASYNC --
at Frame. (/home/daniel/node_modules/puppeteer/lib/helper.js:83:19)
at Page.evaluate (/home/daniel/node_modules/puppeteer/lib/Page.js:792:47)
at Page. (/home/daniel/node_modules/puppeteer/lib/helper.js:84:27)
at Whatsapp. (/home/daniel/node_modules/@open-wa/wa-automate/dist/api/whatsapp.js:329:50)
at step (/home/daniel/node_modules/@open-wa/wa-automate/dist/api/whatsapp.js:44:23)
at Object.next (/home/daniel/node_modules/@open-wa/wa-automate/dist/api/whatsapp.js:25:53)
at /home/daniel/node_modules/@open-wa/wa-automate/dist/api/whatsapp.js:19:71
at new Promise ()
at __awaiter (/home/daniel/node_modules/@open-wa/wa-automate/dist/api/whatsapp.js:15:12)
at Whatsapp.sendText (/home/daniel/node_modules/@open-wa/wa-automate/dist/api/whatsapp.js:326:16)
-- ASYNC --
at Page. (/home/daniel/node_modules/puppeteer/lib/helper.js:83:19)
at Whatsapp. (/home/daniel/node_modules/@open-wa/wa-automate/dist/api/whatsapp.js:329:50)
at step (/home/daniel/node_modules/@open-wa/wa-automate/dist/api/whatsapp.js:44:23)
at Object.next (/home/daniel/node_modules/@open-wa/wa-automate/dist/api/whatsapp.js:25:53)
at /home/daniel/node_modules/@open-wa/wa-automate/dist/api/whatsapp.js:19:71
at new Promise ()
at __awaiter (/home/daniel/node_modules/@open-wa/wa-automate/dist/api/whatsapp.js:15:12)
at Whatsapp.sendText (/home/daniel/node_modules/@open-wa/wa-automate/dist/api/whatsapp.js:326:16)
at /home/daniel/Desktop/Test_NPM/qrcode2.ts:25:9
at step (/home/daniel/Desktop/Test_NPM/qrcode2.ts:33:23)
(node:1883) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1883) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

My code is
const express = require('express')
const path = require("path");
import axios from 'axios';

const wa = require('@open-wa/wa-automate');
import { Whatsapp, decryptMedia, ev} from '@open-wa/wa-automate';
const mime = require('mime-types');
const fs = require('fs');
const ON_DEATH = require('death');
const app = express()
app.use(express.json())

ON_DEATH(async function(signal, err) {
console.log('killing session');
if(globalClient)await globalClient.kill();
})

let globalClient:Whatsapp;
wa.create().then(client => start(client));

async function start(client) {

client.sendText("[email protected]", ' Opa, ?Como q tá?');

}

doesn't follow template

Most helpful comment

@github-actions run


âš¡ Release! âš¡

(async () => {
function exec(cmd) {
  console.log(execSync(cmd).toString());
}

// 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`);
exec(`npm run release-ci`);

//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`);
  })();

All 5 comments

@github-actions run


âš¡ Release! âš¡

(async () => {
function exec(cmd) {
  console.log(execSync(cmd).toString());
}

// 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`);
exec(`npm run release-ci`);

//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 1.9.4 (2020-04-29)

  • Bump release-it from 13.5.5 to 13.5.6 #370
  • Release 1.9.4 d001c8c
  • fix: now able to send message to contact without an existing chat #375 3ac31d8
  • updated license server b075d61
  • updated release-image 4ddb141

@DeLuca92 should be working now.

Thx.
Bro, it's possible make a web interface?
like in php?

@DeLuca92 I don't know php but if you want you can start open-wa/wa-automate-php. Please discuss in the discord.

Was this page helpful?
0 / 5 - 0 ratings