DEV Community

Cover image for WhatsApp Automation
srkomma
srkomma

Posted on • Updated on

WhatsApp Automation

Everyday is an API day: What is WhatsApp Automation?

*WhatsApp is a freeware owned by Facebook which allows users to send text messages and voice messages, make voice and video calls, and share images, documents, user locations, and other media. It can be used on Mobile phone, on PCs using WhatsApp Web or computer application. It's widely used among friends, family, and neighborhood/community groups.*

My nephew Venkat and I are part of a family group on WhatsApp with more than 50 Birthdays and Anniversaries to wish family for in a year and it is easy to forget often given our busy lives. Hence the reason why we wanted to automate a couple of scenarios while also taking advantage this hackathon to learn something new.

  • Send Birthday or Anniversary wishes to the relatives part of the family group.
  • Update profile picture upon uploading any day or occasion specific picture.

We used

  • Windows BAT Scripts
  • Windows Task Scheduler tasks
  • SikuliX Python Desktop Script
  • MuleSoft APIs, File & Email connectors, Java Component to invoke SikuliX Java code, and DataWeave to select data
  • WhatsApp Application on the computer connected to a cell phone.

High Level Flow:

High Level Diagram

High level Logic:

  • Read a CSV file with pre-configured data for sending wishes
  • Look for profile picture to update, if any
  • Send wishes and set the profile picture.
  • We used MuleSoft's file connector to read the CSV file, DataWeave to select data for processing, Java component to invoke a static method with SikuliX Java API code which does all the heavy lifting of the WhatsApp automation, and Email connector to email the log file from the run.
  • We also created Windows Batch Scripts, and Task Scheduler tasks to automatically wake up computer at a certain time, perform the automation, and make the computer go back to sleep again after all activities are done.

RAML:

#%RAML 1.0
types:
  Automation-API-Input:
    description: Automation API input
    example:
      strict: true
      value:
        sikuli_home_folder: "C:\\sikulix"
        sikuli_images_sub_folder: sikuli_images
        system_default_pictures_folder: "C:\\Users\\<username>\\Pictures"
        whatsapp_desktop_exe: WhatsApp.exe
        input_csv_file_name: input_data.csv
        process_done_flag_file: whatsapp_update_done.txt
    properties:
      sikuli_home_folder:
        type: string
      sikuli_images_sub_folder:
        description: Sub-folder in sikuli_home_folder having images needed by Mule Java code
        type: string
      system_default_pictures_folder:
        description: Default pictures folder path on your machine
        type: string
      whatsapp_desktop_exe:
        description: WhatsApp computer application name.
        type: string
      input_csv_file_name:
        description: This is the file name of the CSV file containing the greetings data
        type: string
      process_done_flag_file:
        description: Name of the file that Mule creates after all processing is done
        type: string
title: WhatsApp Automation
baseUri: http://localhost:8081
description: WhatsApp Automation API
mediaType:
  - application/json
version: v1
protocols:
  - HTTP
/whatsapp:
  post:
    displayName: Automation API
    body:
      type: Automation-API-Input
    responses:
      "200":
        description: Success
        body:
          text/plain:
            description: Success Response
            example: "***** Run Date: 20201121 ***** No Data To Process"
            type: string
/whatsapp/healthcheck:
  get:
    displayName: HealthCheck API
    description: External code invokes this API to ensure Mule application is up for further processing
    responses:
      "200":
        description: Success Response
Enter fullscreen mode Exit fullscreen mode

Links to code and other resources

  • GitHub Repository

  • README documents on GitHub have a high level flow, detailed instructions on how to setup, execute code, code logic, and some SikuliX resources.

  1. Main README

  2. Additional README

Video on Setup

Quick demo of the automation

About us

Sreeni Komma, MCD, MCIA
In-depth experience creating custom enterprise solutions and integrations as a technical enthusiast with a passion for software development, solution design, and enterprise application integration / APIs. Certification as a MuleSoft Developer and Integration Architect with experience in MuleSoft solution deployment and design for a wide array of organizations.
LinkedIn

Venkatarami Konudula, M.S. Computer Science @Virginia Tech

Graduating soon and interested in pursuing job opportunities in Full Stack and/or MuleSoft Development.
LinkedIn

Top comments (1)

Collapse
 
roystonlobo profile image
Royston Lobo

Thank you for your submission, Sreeni and Venkatarami!