Closed yaelahsas closed 4 years ago
What's your programming language
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
Just provide link to your php script in the bot.json and in your script receive post request and do processing then return response
How i can get response from web in wbot? Sorry im still learn about this
`<?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]";`
Sorry, in my case i cant get response from web an then send to whatsapp, not how to make response in server
You mean initiate conversation from php to node server?
Yesss, right
You will need to contact @vasani-arpit for that
You use webhook?
The one I use, is what i explained above
Oke i see, thanks for your response :)
@impozzible if you get response from web server , what next to send it to contact whatsapp?
https://drive.google.com/file/d/1XREpk7RroD8UwWk-Kdkh-dj72_L8HS68/view?usp=sharing Check the video here
Thanks i will tryy
@impozzible btw how to add webapi in wbot ? Bcs in bot.json webapi is undefined
You can add it manually, but I don't think it's required so you may leave it out
Btw, can i change type request note "message" but "pesan"? In where i can change? Maybe in inject.js?
maybe I guess so
Okey thankss :)
@impozzible are u adding some code in config of WBOT? bcs i try its not working, in example i just set to your webhook
No just add link in your bot.json
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}!
))`
No, I still don't understand your problem
@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.
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
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
@impozzible do you change inject.js?
Bcs, i try to code simple php like your video buts the no respond if i run wbot
No i did not change inject.js, send your php code, let me check
Screenshot php code and send let me check
@impozzible thiss
I think, you change type to pesan in the library so you need to change type in your php script to pesan also
if i test in post man, result is not change
change type in wa.php to pesan $response = array('text'=>$reply,'type'=>"pesan");
not change the response, if i test in postman. i think php script not get data from postman, and then reply is ididnt understand.
I don't understand you
Give me tutorial about @impozzible
great example @impozzible , this what I need.
@intec-id can u give example to change type message in library?
`<?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
@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
Hello, do you have teamviewer
@impozzible yes i have, can u teach me with teamview?
yes,
@impozzible okey, lets go meeting, or remote control?
remote control
Kindly have your Php script open and then the WBOT server up also
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