WhatsApp Support Bot
To set up your support bot, go to the WhatsApp → Bots menu and register a new support bot using the New ChatBot button.
You can change the bot's functionality in two distinct ways: via JSON or the Visual Editor. Changes made in the editor will be reflected in the JSON and vice versa.

Topics and Questions
The basic structure of the bot is organized into Topics and Questions. Each topic can contain multiple questions.

Programmability (Helper)
Various aspects of the bot can be programmed to better suit your company. You have access to all bot functions directly in the code editor:

Available methods in the helper class:
void ClearAsked()
Clears question and answer history.
void ClearVars()
Clears set variables.
void CloseTicket(String TextMessage)
Ends the conversation.
void Debug(String debugLine)
Adds a debug log.
void DebugVars()
Adds variables to the debug log.
String Deserialize(String json)
Deserializes a JSON string into an object.
Return: Object
void DisableBot()
Disables the bot.
void EnableBot()
Enables the bot.
void DisableTopic(String TopicName)
Disables the topic for the bot.
void EnableTopic(String TopicName)
Enables the topic for the bot.
void EnviaPerguntaPorId(String idPergunta)
Sends a question to the client by the given ID.
String GetVar(String varName)
Retrieves the value of a variable.
Return: String with the variable value.
void GoSub(String idPergunta)
Goes to the specified subroutine.
String HttpPost(String url, String Header, String Body, String ContentType)
Performs an HTTP POST.
Return: String with the returned content after the post.
Boolean isNullOrEmpty(String value)
Checks if the value is null or empty.
Return: true|false
Boolean isValidCnpj(String CNPJ)
Checks if the provided CNPJ is valid.
Return: true|false
Boolean isValidCpf(String Cpf)
Checks if the provided CPF is valid.
Return: true|false
Boolean isValidEmail(String email)
Checks if the provided email is valid.
Return: true|false
Boolean isValidNome(String Name)
Checks if the provided name is valid.
Return: true|false
void LastAskedPop()
Removes the last received answer.
String LoadFromFile(String FileName)
Loads the content of a file.
Return: String with the file content.
String LoadUrl(String url)
Loads content from an external URL.
Return: String with the content.
void ParseBadWordsFromText(String fileContent)
Adds to the list of obscene words.
void ParseVariablesFromJSON(String fileContent)
Sets environment variables according to the provided JSON.
void ParseVariablesFromText(String fileContent)
Sets environment variables according to the provided text.
String SaveVariablesToJSON()
Returns JSON containing the variables and their respective values.
String Serialize(Object obj)
Serializes an object to a JSON string.
Boolean RegularExpressionMatch(String regularExpression, String value)
Checks if the value matches the provided regular expression.
Return: true|false
String RegularExpressionValue(String regularExpression, String value, Int32 captureGroup)
Checks if the value matches the provided regular expression.
Return: String with the value of the specified group.
void SendMessageTemplate(String TemplateIdOrName)
Sends a message from a pre-registered template.
void SendMessageText(String TextMessage)
Sends a text message.
void SetPerguntaAtiva(String idPergunta)
Sets the question as active.
void SetTag(String newTag)
Adds a tag to the contact.
void SetVar(String varName, String|Object varValue)
Sets a variable.
void Sleep(int miliSeconds)
Pauses processing.
void StartTyping()
Sends "Typing" status to the client.
void TransferTicket(String DestinationLogin)
Transfers the ticket to an agent.
void UpdateProfileStatus(String newStatus)
Updates the profile status.
Dynamic Variables
Variables that will be replaced according to the current contact.
| Variable | Example | Note |
|---|---|---|
$perfilname$ | José Maria dos Santos | Replaced by phone number if not available. |
$perfil-pushname$ | José Maria | Replaced by phone number if not available. |
$jid$ | 5511998765432@s.whatsapp.net | |
$id_atendimento$ | 219482 | |
$id_profile$ | 30129292 | |
$robo_ativo$ | True/False | |
$pushname$ | Support Center | WhatsApp display name |
$ou(value1|value2)$ | value 1 | Randomly alternates between the values |
Bot Example
Copy the example of a pre-configured bot below to learn the basic operation of the tool:
{
"Topicos": [
{
"Id": "1",
"Name": "Commands",
"CondicaoInicio": "",
"CondicaoTermino": "",
"CondicaoInicioResultado": true,
"CondicaoTerminoResultado": false,
"Enabled": true,
"PerguntasPassivas": [
{
"Perguntas": [
{
"IdFrase": 0,
"ListOfDependencies": [],
"DependencyCount": 0,
"Texto": "/FIRST_TIME_USER",
"OnAswerScript": "",
"OnEvaluateScript": ""
}
],
"RespostaPossiveis": [],
"Respostas": [],
"respostaIndex": 0,
"OnAnswerScript": "Boolean OnExecute(SalesBot.LambaHelper helper)\n{\n Boolean retorno = false;\n\n try \n {\n helper.Debug(\"Starting OnExecute - $NameContext$ - $NameObjext$\");\n\n // your code\n helper.EnviaPerguntaPorId(\"QUAL_NOME\");\n \n retorno = true;\n }\n catch(Exception ex)\n {\n helper.Debug(ex);\n }\n finally\n {\n helper.Debug(\"End OnExecute - $NameContext$ - $NameObjext$\");\n }\n \n return retorno;\n}",
"MaxCount": 0,
"UsedCount": 0,
"Id": "FIRST_TIME_USER",
"CanEvaluate": true
}
],
"PerguntasAtivas": [],
"OnAnswerScript": "",
"OnStartScript": "",
"OnEndScript": "",
"CanEvaluate": true
},
{
"Id": "3",
"Name": "Data Topic",
"CondicaoInicio": "",
"CondicaoTermino": "",
"CondicaoInicioResultado": true,
"CondicaoTerminoResultado": false,
"Enabled": true,
"PerguntasPassivas": [
{
"Perguntas": [],
"RespostaPossiveis": [
{
"Resposta": "RIGHT",
"OnAnswerScript": "\nBoolean OnExecute(SalesBot.LambaHelper helper)\n {\n Boolean retorno = false;\n\n try \n {\n helper.Debug(\"Starting OnExecute - $NameContext$ - $NameObjext$\");\n\n // your code\n String name = \"$0$\";\n helper.SetVar(\"NAME\",name);\n helper.ClearAsked();\n helper.EnviaPerguntaPorId(\"QUAL_CPF\");\n retorno = true;\n }\n catch(Exception ex)\n {\n helper.Debug(ex);\n }\n finally\n {\n helper.Debug(\"End OnExecute - $NameContext$ - $NameObjext$\");\n }\n \n return retorno;\n }\n",
"OnValidationScript": "\n Boolean OnEvaluate(SalesBot.LambaHelper helper)\n {\n Boolean retorno = false;\n\n try \n {\n helper.Debug(\"Starting OnEvaluate - $NameContext$ - $NameObjext$\");\n\n // your code\n retorno = helper.isValidNome(\"$0$\");\n }\n catch(Exception ex)\n {\n helper.Debug(ex);\n }\n finally\n {\n helper.Debug(\"End OnEvaluate - $NameContext$ - $NameObjext$\");\n }\n \n return retorno;\n }\n",
"Default": false,
"ClearLast": true,
"RespostaRegEx": null,
"VariavelNome": null,
"VariavelValor": null
},
{
"Resposta": "WRONG",
"OnAnswerScript": "\nBoolean OnExecute(SalesBot.LambaHelper helper)\n {\n Boolean retorno = false;\n\n try \n {\n helper.Debug(\"Starting OnExecute - $NameContext$ - $NameObjext$\");\n\n // your code\n helper.StartTyping();\n helper.Sleep(3000);\n helper.SendMessageText(\"Sorry, I didn't understand... Could you please type your FULL name again?\");\n helper.Sleep(3000);\n helper.EnviaPerguntaPorId(\"QUAL_NOME\");\n\n retorno = true;\n }\n catch(Exception ex)\n {\n helper.Debug(ex);\n }\n finally\n {\n helper.Debug(\"End OnExecute - $NameContext$ - $NameObjext$\");\n }\n \n return retorno;\n }\n",
"OnValidationScript": "\n Boolean OnEvaluate(SalesBot.LambaHelper helper)\n {\n Boolean retorno = false;\n\n try \n {\n helper.Debug(\"Starting OnEvaluate - $NameContext$ - $NameObjext$\");\n\n // your code\n retorno = !helper.isValidNome(\"$0$\");\n }\n catch(Exception ex)\n {\n helper.Debug(ex);\n }\n finally\n {\n helper.Debug(\"End OnEvaluate - $NameContext$ - $NameObjext$\");\n }\n \n return retorno;\n }\n",
"Default": true,
"ClearLast": false,
"RespostaRegEx": null,
"VariavelNome": null,
"VariavelValor": null
}
],
"Respostas": [],
"respostaIndex": 0,
"OnAnswerScript": "Boolean OnExecute(SalesBot.LambaHelper helper)\n{\n Boolean retorno = false;\n\n try \n {\n helper.Debug(\"Starting OnExecute - $NameContext$ - $NameObjext$\");\n\n // your code\n String name = helper.GetVar(\"NAME\");\n \n if(!helper.isValidNome(name))\n {\n helper.StartTyping();\n helper.Sleep(100);\n helper.SendMessageText(\"Hello! Who am I speaking with?\");\n } \n retorno = true;\n }\n catch(Exception ex)\n {\n helper.Debug(ex);\n }\n finally\n {\n helper.Debug(\"End OnExecute - $NameContext$ - $NameObjext$\");\n }\n \n return retorno;\n}",
"MaxCount": 0,
"UsedCount": 0,
"Id": "QUAL_NOME",
"CanEvaluate": true
},
{
"Perguntas": [],
"RespostaPossiveis": [
{
"Resposta": "RIGHT",
"OnAnswerScript": "\nBoolean OnExecute(SalesBot.LambaHelper helper)\n {\n Boolean retorno = false;\n\n try \n {\n helper.Debug(\"Starting OnExecute - $NameContext$ - $NameObjext$\");\n\n // your code\n helper.SetVar(\"CPF\", helper.GetVar(\"0\"));\n helper.EnviaPerguntaPorId(\"END\");\n retorno = true;\n }\n catch(Exception ex)\n {\n helper.Debug(ex);\n }\n finally\n {\n helper.Debug(\"End OnExecute - $NameContext$ - $NameObjext$\");\n }\n \n return retorno;\n }\n",
"OnValidationScript": "\n Boolean OnEvaluate(SalesBot.LambaHelper helper)\n {\n Boolean retorno = false;\n\n try \n {\n helper.Debug(\"Starting OnEvaluate - $NameContext$ - $NameObjext$\");\n\n // your code\n retorno = helper.isValidCpf(\"$0$\");\n }\n catch(Exception ex)\n {\n helper.Debug(ex);\n }\n finally\n {\n helper.Debug(\"End OnEvaluate - $NameContext$ - $NameObjext$\");\n }\n \n return retorno;\n }\n",
"Default": false,
"ClearLast": true,
"RespostaRegEx": null,
"VariavelNome": null,
"VariavelValor": null
},
{
"Resposta": "WRONG",
"OnAnswerScript": "\nBoolean OnExecute(SalesBot.LambaHelper helper)\n {\n Boolean retorno = false;\n\n try \n {\n helper.Debug(\"Starting OnExecute - $NameContext$ - $NameObjext$\");\n helper.SendMessageText(\"Invalid CPF. Please enter it again:\");\n // your code\n retorno = true;\n }\n catch(Exception ex)\n {\n helper.Debug(ex);\n }\n finally\n {\n helper.Debug(\"End OnExecute - $NameContext$ - $NameObjext$\");\n }\n \n return retorno;\n }\n",
"OnValidationScript": "\n Boolean OnEvaluate(SalesBot.LambaHelper helper)\n {\n Boolean retorno = false;\n\n try \n {\n helper.Debug(\"Starting OnEvaluate - $NameContext$ - $NameObjext$\");\n\n // your code\n String CPF = helper.GetVar(\"0\");\n\n retorno = !helper.isValidCpf(CPF);\n }\n catch(Exception ex)\n {\n helper.Debug(ex);\n }\n finally\n {\n helper.Debug(\"End OnEvaluate - $NameContext$ - $NameObjext$\");\n }\n \n return retorno;\n }\n",
"Default": true,
"ClearLast": false,
"RespostaRegEx": null,
"VariavelNome": null,
"VariavelValor": null
}
],
"Respostas": [],
"respostaIndex": 0,
"OnAnswerScript": "Boolean OnExecute(SalesBot.LambaHelper helper)\n{\n Boolean retorno = false;\n\n try \n {\n helper.Debug(\"Starting OnExecute - $NameContext$ - $NameObjext$\");\n\n // your code\n helper.Debug(\"Starting OnExecute - $NameContext$ - $NameObjext$\");\n\n String cpf = helper.GetVar(\"CPF\");\n String name = helper.GetVar(\"NAME\");\n \n if(!helper.isValidCpf(cpf))\n {\n helper.StartTyping();\n helper.Sleep(100);\n helper.SendMessageText(name + \", please enter your <b>CPF</b> to continue:\");\n } \n retorno = true;\n }\n catch(Exception ex)\n {\n helper.Debug(ex);\n }\n finally\n {\n helper.Debug(\"End OnExecute - $NameContext$ - $NameObjext$\");\n }\n \n return retorno;\n}",
"MaxCount": 0,
"UsedCount": 0,
"Id": "QUAL_CPF",
"CanEvaluate": true
},
{
"Perguntas": [],
"RespostaPossiveis": [],
"Respostas": [],
"respostaIndex": 0,
"OnAnswerScript": "\nBoolean OnExecute(SalesBot.LambaHelper helper)\n {\n Boolean retorno = false;\n\n try \n {\n helper.Debug(\"Starting OnExecute - $NameContext$ - $NameObjext$\");\n\n helper.SendMessageText(\"Thank you!\\n\\nWe will contact you as soon as possible.\");\n\n // your code\n retorno = true;\n }\n catch(Exception ex)\n {\n helper.Debug(ex);\n }\n finally\n {\n helper.Debug(\"End OnExecute - $NameContext$ - $NameObjext$\");\n }\n \n return retorno;\n }\n",
"MaxCount": 0,
"UsedCount": 0,
"Id": "END",
"CanEvaluate": true
}
],
"PerguntasAtivas": [],
"OnAnswerScript": "",
"OnStartScript": "",
"OnEndScript": "",
"CanEvaluate": true
}
],
"HistoricoConversa": [],
"BadWords": null,
"BadWordTopic": null,
"Enabled": true,
"OnLoadScript": "",
"OnUnLoadScript": "",
"OnInputScript": "",
"OnTimerScript": "",
"OnIdleScript": "",
"OnAnswerScript": "",
"OnBadWordScript": "",
"BadWordTopicName": "",
"IdCount": 0,
"OnUnknowScript": "",
"IdleTimeInSecconds": 60,
"TimerTimeInSecconds": 5
}
Create your bot, paste the content above into the JSON editor and click Import at the bottom of the page.
Save your bot and then run the test.
Test your bot
Before putting the bot into use, it is crucial to run all necessary tests. Use the available testing tool:

To simulate the support ticket created by the user in the testing environment, there are two special commands:

| Command | Execution Order | Function |
|---|---|---|
/FIRST_TIME_USER | 3 | Sent in a new conversation (new user), when there has been NO message exchange in the last 30 days. |
/START_SESSION | 4 | Sent at the beginning of the conversation, when there HAS BEEN message exchange in the last 30 days. |
/FIRST_TIME_USER_FROM_ME | 1 | Sent in a new conversation (no message exchange in the last 30 days) initiated by the system (by an agent or other means, not by the user). |
/START_SESSION_FROM_ME | 2 | Sent in a conversation started by the agent or system (not by the user), where there has been message exchange in less than 30 days. |
Both commands will execute the topic with the same name and start your script. These commands are executed automatically by the system in the production environment.
Remember to create the question with the entry /START_SESSION or /FIRST_TIME_USER to process these commands and start the bot support session.