vasani-arpit / WBOT

A simple Web based BOT for WhatsApp™ in NodeJS 😜. Working as of 📅 Feb 4th, 2024
Other
989 stars 314 forks source link

Someone can give me example to use webhook? #105

Closed yaelahsas closed 4 years ago

yaelahsas commented 4 years ago

im new to use wbot, i try to learn about bot. i think i can make some bot can response question like simsimi but i dont know to implement in wbot. can you give me example to make simsimi or implement webhook

impozzible commented 4 years ago

What's your programming language

yaelahsas commented 4 years ago

Php, In case how i can config wbot to connect with server with response json? Bcs in documentation, we have to add rule in wbot, but i not understand where the rule create

impozzible commented 4 years ago

Just provide link to your php script in the bot.json and in your script receive post request and do processing then return response

yaelahsas commented 4 years ago

How i can get response from web in wbot? Sorry im still learn about this

impozzible commented 4 years ago

`<?php header('Access-Control-Allow-Origin: *'); header("Access-Control-Allow-Credentials: true"); header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS'); header('Access-Control-Max-Age: 1000'); header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token , Authorization'); // file_put_contents("wh.txt",$postdata); $data = file_get_contents("php://input"); $data = json_decode($data,true); $text = $data['text']; $type = $data['type']; $user = $data['user'];

$response = array("text" => "Kilon sele my nigga", "type" => "message"); $response = json_encode($response); echo "[$response]";`

yaelahsas commented 4 years ago

Sorry, in my case i cant get response from web an then send to whatsapp, not how to make response in server

impozzible commented 4 years ago

You mean initiate conversation from php to node server?

yaelahsas commented 4 years ago

Yesss, right

impozzible commented 4 years ago

You will need to contact @vasani-arpit for that

yaelahsas commented 4 years ago

You use webhook?

impozzible commented 4 years ago

The one I use, is what i explained above

yaelahsas commented 4 years ago

Oke i see, thanks for your response :)

yaelahsas commented 4 years ago

@impozzible if you get response from web server , what next to send it to contact whatsapp?

impozzible commented 4 years ago

https://drive.google.com/file/d/1XREpk7RroD8UwWk-Kdkh-dj72_L8HS68/view?usp=sharing Check the video here

yaelahsas commented 4 years ago

Thanks i will tryy

yaelahsas commented 4 years ago

@impozzible btw how to add webapi in wbot ? Bcs in bot.json webapi is undefined

impozzible commented 4 years ago

You can add it manually, but I don't think it's required so you may leave it out

yaelahsas commented 4 years ago

Btw, can i change type request note "message" but "pesan"? In where i can change? Maybe in inject.js?

impozzible commented 4 years ago

maybe I guess so

yaelahsas commented 4 years ago

Okey thankss :)

yaelahsas commented 4 years ago

@impozzible are u adding some code in config of WBOT? bcs i try its not working, in example i just set to your webhook

impozzible commented 4 years ago

No just add link in your bot.json

yaelahsas commented 4 years ago

can i see your webapi function? bcs i add your link in my bot.json not working. or i have to create some code like

`const express = require('express') const app = express() const port = 3001 //allowing requests from outside of the domain app.use(function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); // update to match the domain you will make the request from res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type,Accept"); next(); });

app.post('/api/incoming-webhook', (req, res) => res.send( [{ "text": "Look, Reply from Webhook!", "type": "message" }] )) app.get('/', (req, res) => res.send('Hello World!'))

app.listen(port, () => console.log(Example app listening on port ${port}!))`

impozzible commented 4 years ago

No, I still don't understand your problem

yaelahsas commented 4 years ago

@impozzible if i add your link to bot.json why still not connected to your link, but in your video you just add link and its working fine.

beecoder77 commented 4 years ago

well, same as me, I have changed the webhook (here I use locahost) and the webapi setting is true, when I chat to the bot, the server / webhook does not receive any requests from wbot

@impozzible @vasani-arpit @yaelahsas

impozzible commented 4 years ago

Are you sure you configured your server correctly, I am currently using the api for this now, and it's working perectly. https://cutt.ly/covid19bot

yaelahsas commented 4 years ago

@impozzible do you change inject.js?

yaelahsas commented 4 years ago

Bcs, i try to code simple php like your video buts the no respond if i run wbot

impozzible commented 4 years ago

No i did not change inject.js, send your php code, let me check

impozzible commented 4 years ago

Screenshot php code and send let me check

yaelahsas commented 4 years ago

@impozzible thiss image

impozzible commented 4 years ago

I think, you change type to pesan in the library so you need to change type in your php script to pesan also

yaelahsas commented 4 years ago

if i test in post man, result is not change image

impozzible commented 4 years ago

change type in wa.php to pesan $response = array('text'=>$reply,'type'=>"pesan");

yaelahsas commented 4 years ago

not change the response, if i test in postman. i think php script not get data from postman, and then reply is ididnt understand.

impozzible commented 4 years ago

I don't understand you

yaelahsas commented 4 years ago

Give me tutorial about @impozzible

intec-id commented 4 years ago

great example @impozzible , this what I need.

yaelahsas commented 4 years ago

@intec-id can u give example to change type message in library?

intec-id commented 4 years ago

`<?php header('Access-Control-Allow-Origin: *'); header("Access-Control-Allow-Credentials: true"); header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS'); header('Access-Control-Max-Age: 1000'); header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token , Authorization'); // file_put_contents("wh.txt",$postdata); $data = file_get_contents("php://input"); $data = json_decode($data,true); $text = $data['text']; $type = $data['type']; $user = $data['user'];

$response = array("text" => "Kilon sele my nigga", "type" => "message"); $response = json_encode($response); echo "[$response]";`

this sample work perfect, you just need set-up webhook in bot.json @yaelahsas

yaelahsas commented 4 years ago

@impozzible @intec-id why response default from server not printed in console ? and please you test my webhook, are running well in your ? https://test-wa.000webhostapp.com/wa.php

impozzible commented 4 years ago

Hello, do you have teamviewer

yaelahsas commented 4 years ago

@impozzible yes i have, can u teach me with teamview?

impozzible commented 4 years ago

yes,

yaelahsas commented 4 years ago

@impozzible okey, lets go meeting, or remote control?

impozzible commented 4 years ago

remote control

impozzible commented 4 years ago

Kindly have your Php script open and then the WBOT server up also

impozzible commented 4 years ago
Screenshot 2020-03-25 at 2 57 16 PM