The Way Of Life
Google

Monday, November 20, 2023

Aplikasi untuk Mengirim Pesan WhatsApp Otomatis

Kali ini saya akan sharing tentang bagaimana cara untuk mengirim pesan WhatsApp secara otomatis menggunakan aplikasi yang kita buat sendiri. Ada banyak cara yang bisa anda temukan di internet. Artikel yang saya tulis ini adalah salah satu caranya dan sudah saya buktikan berhasil.

Langkah langkahnya antara lain :

  1. Proses pengambilan data. Pada proses ini ada beberapa cara, antara lain menggunakan koneksi ke database langsung atau menggunakan API ( Application Programming Interface). Cara yang terakhir ini biasanya dipergunakan jika kita mengakses sistem yang dibuat oleh orang/pihak lain.
  2. Proses pengolahan data. Pada proses ini data yang sudah diterima harus diolah dahulu. Misal dalam tema kali ini adalah pengiriman pesan. Maka data mentah yang berupa misal nama,  alamat dan nomor telepon, perlu ditambah kalimat pesan sesuai dengan kebutuhan yang diinginkan.
  3. Proses pengiriman pesan. Pengiriman pesan WA untuk broadcast khususnya saat ini dimungkinkan melalui API yang disediakan rekanan WhatsApp yang ada di indonesia. Untuk saat ini karena kebetulan saya menggunakan produk dari Maxchat. Bukan karena saya ingin mempromosikan maxchat.

IMPLEMENTASI

Karena kebetulan aplikasi yang saya buat adalah menarik data dari sistem pihak lain, maka saya menggunakan API yang telah disediakan oleh vendor. Aplikasi yang saya buat adalah aplikasi Notifikasi WA di sebuah sekolah internasional. Aplikasi ini mengirimkan data ke orang tua murid jika salah satu anaknya masuk ke klinik di sekolah karena sudah hal.

  1. Proses memanggil fungsi API ke Skyward ( Sistem Informasi Akademik yang digunakan sekolah tersebut) saya kebetulan menggunakan bahasa pemogramaman Microsoft Visual Basic. Sebenarnya dengan bahasa pemrograman apa saja juga memungkinkan asal ada fungsi HTPP Request. Proses ini biasanya memerlukan beberapa parameter yaitu, alamat URL, user, password dan token. Ada bisa membaca detail-nya di tulisan saya sebelumnya disini.
  2. Pengolahan data. Setelah data diterima aplikasi (biasanya dalam bentuk JSON ) melalui http request yaitu berupa field student id, student name, status orang tua ( Ayah, Ibu, Guardian, Lain-nya ), Nama Ayah, nomor HP Ayah, Nama Ibu nomor HP Ibu, Nama Guardian, Nomor HP Guardian, Kelas, Tanggal Transaksi, Alasan masuk klinik, treatment, comment, dsb.  Maka perlu ditambahkan pesan tambahan agar pesan enak dan layak dibaca oleh orang tua murid yang nantinya akan menerima pesan WA. Juga untuk penyimpanan data ke database (MySQL/MariaDB) untuk mencatat error log serta mengecek apakah pesan tersebut sudah dikirim atau belum sehingga tidak ada duplikasi pengiriman pesan WA. 
  3. Proses pengiriman data. Kebetulan saya menggunakan API WA dari Maxchat. Sebanarnya ada banyak vendor rekanan WA di Indonesia selain Maxchat. Hanya karena kebetulan saya menggunakan API dari Maxchat maka fitur fitur dari Maxchat yang akan saya bahas. Parameter yang akan diperoleh dari maxchat adalah url endopoint untuk API.

Jika anda sudah mendaftar di maxchat maka anda akan mendapatkan link URL dan authorization key, lalu dokumentasi API yang bisa anda explore. Contoh link ada di bawah ini.

URL : https://core.maxchat.id/ nama-perusahaan /api/messages?skipBusy=true

Authorization : passkey

Dokumentasi : https://core.maxchat.id/nama-perusahaan/docs

  

Contoh format pesan text yang dikirim dalam bentuk JSON:

 {

"to":"0810000000000",

"type":"text",

"text":"Dear, *Mr. xxxx*\n \nWe would like to inform you that *Your Son* has visited school clinic.\n \nDate: 00 Nov 2023\nTime: 07:48:32 am\nOffice Visit Reason(s): Runny Nose\nTreatment(s): Apply Vicks VapoRub\nDisposition(s): Return to Class\nExamined By: Nurse \nComment: \nNotes: \n \n \nThank You.\n School Name \nFor further information please contact the school admin at\nhttps://wa.me/628200000000\n*This is an automated message - do not reply*",

"useTyping": true

}

Di maxchat juga disediakan fitur untuk mengecek apakah sebuah nomor wa aktif atau tidak dengan URL API : https://core.maxchat.id/nama-perusahaan/api/check?phone=081000000000'


Dengan respon balik exists  : true (artinya nomornya Aktif)  / false (Nomornya tidak aktif)

Juga karena ini adalah sebuah sekolah, maka tidak setiap waktu aplikasi ini aktif, program akan mulai aktif jam 7.30 pagi dan non aktif atau "tidur" jam 17.00, pada jam 12.00 siang hanya untuk mengecek bahwa program ini masih aktif berjalan saja. Pesan WA biasanya dikirim ke admin untuk mengetahui program masih berjalan atau error karena banyak sebab.

Demikian gambaran jika anda ingin membuat aplikasi notifikasi WA menggunakan bahasa pemogroman apapun dan API WA dari vendor apapapun karena pada intinya prosesnya akan sama.

Semoga bermanfaat.

 

Software :

Microsoft Visual Basic 6.0

MySQL / MariaDB

WhatsApp

Operating System : Windows 10

API Data : Skyward

API WA : Maxchat

Related links:

API Call Using Visual Basic 6 (JSON Response)

How to Make WhatsApp Office Visit / Clinic Notification on Skyward


Labels: , , , ,

Saturday, February 11, 2023

API Call Using Visual Basic 6 (JSON Response)


Today. I’m gonna show you how to make API (Application Programming Interface) Call using Microsoft Visual Basic 6. And the first step that you have to do is install Visual Basic, I’m using Visual Basic 6 by the way.

First, you must create Visual Basic Project and then go to Project – References , Add Microsoft XML v6.0 and then click OK.


Make a Procedure let say GetRequest


Public Sub GetRequest

Dim xmlhttp As New MSXML2.XMLHTTP60

Dim url as String

Dim Response as String


‘set url


url  = https://api.yourwebsite.com

xmlhttp.Open “POST”, url, False


‘set header

xmlhttp.setRequestHeader "Host:", "api.your.api.url.destionation.com"

xmlhttp.setRequestHeader " Key:", "xyz"

xmlhttp.setRequestHeader " Token:", "$2a$10$ "

xmlhttp.setRequestHeader "Origin:", "http://web.com"

xmlhttp.setRequestHeader "Content-Type", "application/json"


‘set body

sEntityBody = "{" + vbCrLf + """reference_id"":999," + vbCrLf

sEntityBody = sEntityBody & """image""" & ":" & Base64StringImage & vbCrLf & "}"

xmlhttp.send " " + sEntityBody


‘if status 200 ( success )

If xmlhttp.status = "200" Then

    Response = xmlhttp.responseText

    Set xmlhttp = Nothing

When we receive a response from server than we must parse JSON with JSON Parser

    Set p = JSON.parse(Response)

JSON parser for Visual Basic you can download from here and add to Project Modules.

If we want to extract data from JSON we can user object pointer like below :

Text1.text = P.item(“data” .Item("province").Item("raw")

If we want to extract data from members of the item we can code like this below :

For I = 1 To p.Item("data").Item("member").Count()

p.Item("data").Item("member")(I).Item("name")

Next I

End if


Hope this article help you.

Download Source Code API Call VB 6 here 

Software :

Microsoft Visual basic 6.0

JSON Parser  Class Library

Operating System : 

Windows 10 Pro


related links :

Labels: , ,

Friday, May 18, 2012

Visual Basic - JSON



One time, I was asked by one of the customers, "Budy, Can I run a program that you created from my house (but the database server is in her office) ?", My answer is "Yes, if the internet speed is fast enough!"
"If I was in America,
Can I (her daugther lived in USA) ?" "Yes, You can" I replied. I talk to myself that with a Desktop Application that was built with Visual Basic and Microsoft SQL Server as Database Server using ADO Connection, it would be very hard to run through the Internet.  
The first solution  is to create a Web Based application that can be accessed from anywhere. But it requires me to create code from scratch and it takes a very long time. I was thinking how to combine the advantages of Web Applications and Desktop Application, one of which is to use SOAP. But when I was building an Android application, the answer is JSON. Yes, with JSON you can create desktop applications that can access the database from anywhere in the world with internet network, and is much faster because it uses a web service. So when you connect with your local network you can use a standard connection such as ADO, and when you are traveling abroad you can still access the database via JSON with DESKTOP application. It's like "hybrid system" that can run with two different "engine". Here's my video show how JSON connect to Microsoft SQL Server , i've used Sierra Modem to create internet connection.


related links:

JSON

VB JSON Parser

WinHttpRequest object


contoh source code :

Cara mengakses data Json menggunakan Visual Basic 6

Cara menampilkan Json ke Grid VB6, source asli diambil dari sini



Labels: , ,

Wednesday, May 09, 2012

How Fast JSON on Android ?


This time, I will show you, how fast Android Application parsed JSON from Microsoft SQL Server. I've used Android Emulator ( AVD Manager ), perhaps it will be so much faster on the real Android handset. First I check my speed connection with speedtest.net, and here is the result

And then i check signal bar on my modem, and here is the result 


I will query 1478 records from Microsoft SQL Server via internet using PHP web service from my house, it takes at least 10 seconds, on local network it takes at least 5 second, you can checked at this video.


When I use keyword for searching the records it takes under 2 seconds.

 

That means, JSON is fast enough to transfer data from Microsoft SQL Server to Android.

related links:




Labels: , , , , , ,