-
Notifications
You must be signed in to change notification settings - Fork 20
Use without extension
boehlergerman edited this page May 5, 2019
·
1 revision
To start it is necessary to have a registered instance of whatsapp web, and then copy the code contained in the file WappBot.js (See the configuration section for more details, otherwise the code contains default settings). Once copied and configured correctly, open your browser console F12 and paste the code.
you must have a valid whatsapp account and access to whatsapp web
Default configuration:
{
useApi: false,
uriApi: "https://wapp-bot.herokuapp.com/message",
ignoreChat: [],
messageInitial: {
text: "Hello I'm WappBot send a reply \n",
image: null
},
messageIncorrect: "Incorrect option entered, we remind you that the options are: \n",
messageOption: {
"@Date": {
text: new Date().toLocaleDateString(),
image: null
},
"@Christmas": {
text: (() => {
let myDate = new Date();
let cmas = Date.parse("Dec 25, " + myDate.getFullYear())
let today = Date.parse(myDate)
let daysToChristmas = Math.round((cmas - today) / (1000 * 60 * 60 * 24))
if (daysToChristmas == 0)
return "Today is Christmas ... Merry Christmas!"
if (daysToChristmas < 0)
return "Christmas was " + -1 * (daysToChristmas) + " days ago.";
if (daysToChristmas > 0)
return "There are " + daysToChristmas + " days to Christmas!"
})(),
image: null
}
}Options:
useApi [Bool] [Default False], allows you to use an API for message processing,
see the DialogFlow-Nodejs-WappBot repository.
uriApi [String] URL of the api you wish to consult,
you can use the proposed API, it's free :)
[WappBot-API](https://github.com/boehlergerman/DialogFlow-Nodejs-WappBotAPI)
ignoreChat [Array] prevents repeated messages, preventing a "hello" from being sent again
when an incorrect option is entered
messageInitial [Object] configuration of the first message to be sent to the chat
| that generated an incoming message
|
|-> text [String | Self-Invoking Anonymous Function] Welcome text
|
|-> image [String] [Default Null] [Support Base64 Full Format | URL IMAGE]
image to be sent together with the welcome text
messageIncorrect [String] reply message in case an incorrect option is entered
messageOption [Object] configuration of the response options that are enabled for the user
|
|
|-> KeyOption [String] identifier to be shown to the user, it is convenient to use a special
| character at the beginning such as @ # $,
| to avoid misinterpreting the user's message.
|
|-> text [String | Self-Invoking Anonymous Function]
| Text to display when the user enters the option properly
|
|-> image [String] [Default Null] [Support Base64 Full Format | URL IMAGE]
image to be sent together with the text of the desired option
remember that by using this mode, you may have problems using images due to the security block contained in all modern CSP browsers. What is CSP?