To integrate WhatsApp with ScriptCase, we will be using a specific API called Chat-API, it is a paid service that costs $ 39 per month and there is a 3-day trial.
The first of the steps and the most important is to have an account already registered on the page for later use, to verify or register it can be done through this link: https://chat-api.com/en/
To try it for free, you just have to click on this option:
Once inside the indicated page, we will need an API URL and a Token.
Within the API it generates a code and a Token that will allow us to link the API with the tool.
Then you must scan the QR code with your WhatsApp account from the corresponding phone to send the messages.
Once the account is linked, it will show as authenticated:
Then tests could be done to verify that everything is correct using this example and placing a phone number to send the message:
To use this tool within the ScriptCase we have a macro called sc_send_whatsapp: https://www.scriptcase.net/docs/en_us/v9/manual/14-macros/02-macros/#sc_send_whatsapp
This macro receives an array as a configuration parameter that contains the name of the API set in Scriptcase, the message and the destination number.
The parameters that will be used are:
- profile: Here you will be informed of the name of the API configured in the Scriptcase interface.
- message: This parameter informs the message that will be sent through the macro.
- to: Provide the destination number of the message.
$ arr_settings = array ( 'profile' => 'ChatAPI', 'message' => 'Test whatsapp', 'to' => '558182499699' );
sc_send_whatsapp ($ arr_settings);
- To link it with the ScriptCase we must do the following:
1 – In the Tools / API option we will make the respective configuration with the Chat API
In the URL and Auth Token fields, the values indicated in the first steps obtained from the Chat page are placed API.
2 – We create an application of type Blank
3 – Once the application is created within the onExecute event, the macro sc_send_wahtsapp must be used to place the sending parameters:
Reference video: https://youtu.be/pGTpdYIQDms