Create an automation for WhatsApp's chat app? I have the following code which uses the user's clipboard to WhatsApp's online API.
on run {input, parameters}
    set text1 to the clipboard
    do shell script &quot;open https://api.whatsapp.com/send?phone=&quot; &amp; text1
    return input
end run

Now I want to check if the number matches the international code to use in WhatsApp's API correctly.
For example, if I copied a number 021 123456, I want to replace the first few digits with +994021 123456. What happened here is replace the first 0 with +994.
However if the number already starts with +994 then there is no need to amend it.
How do I create a code to do this?
Ok, I've figured it out myself. Putting it out here if anyone needed it in the future.
 on run {input, parameters}
        set text1 to the clipboard
        if first character of text1 is &quot;0&quot; then
            set text2 to 1 - text1 as integer
            do shell script &quot;open https://api.whatsapp.com/send?phone=&quot; &amp; &quot;994&quot; &amp; 1 - text2
            return
        end if
        do shell script &quot;open https://api.whatsapp.com/send?phone=&quot; &amp; text1
        return input
 end run