<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Wala Al Ramadhani on Medium]]></title>
        <description><![CDATA[Stories by Wala Al Ramadhani on Medium]]></description>
        <link>https://medium.com/@wala.saiif?source=rss-26033edd4440------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*j3WoOLIxsYYjsHxd</url>
            <title>Stories by Wala Al Ramadhani on Medium</title>
            <link>https://medium.com/@wala.saiif?source=rss-26033edd4440------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 06:57:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wala.saiif/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automate WhatsApp Messaging with Python: Bulk Messages from a CSV File]]></title>
            <link>https://medium.com/@wala.saiif/automate-whatsapp-messaging-with-python-bulk-messages-from-a-csv-file-cef44c63cf5f?source=rss-26033edd4440------2</link>
            <guid isPermaLink="false">https://medium.com/p/cef44c63cf5f</guid>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[whatsapp]]></category>
            <category><![CDATA[whatsapp-business]]></category>
            <dc:creator><![CDATA[Wala Al Ramadhani]]></dc:creator>
            <pubDate>Sat, 14 Dec 2024 20:10:03 GMT</pubDate>
            <atom:updated>2024-12-14T20:10:03.088Z</atom:updated>
            <content:encoded><![CDATA[<p>Automating bulk WhatsApp messages using <strong>Python</strong> can save you time and effort, especially for business communications or personal projects. With <strong>Selenium</strong>, you can interact with WhatsApp Web directly, sending personalized messages to any contact without restrictions. Unlike the <strong>WhatsApp Business API</strong>, which doesn’t allow you to use your personal app and requires pre-approved templates and phone numbers, Selenium gives you full flexibility to automate messaging just like a real user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BQYTL6NkUiLf2ZFC" /><figcaption>Photo by <a href="https://unsplash.com/@agforl24?utm_source=medium&amp;utm_medium=referral">Tai Bui</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Prerequisites</h3><p>Before getting started, ensure that you have:</p><ol><li><strong>Python Installed</strong>: Download and install Python from <a href="https://www.python.org/">python.org</a>.</li><li><strong>Google Chrome</strong>: Install the Chrome browser on your computer.</li><li><strong>ChromeDriver</strong>: Download the version of ChromeDriver that matches your Chrome browser version from <a href="https://developer.chrome.com/docs/chromedriver/downloads">ChromeDriver Downloads</a>. And place the chromedriver.exe file in an accessible folder.</li><li><strong>Selenium Library</strong>: Install Selenium for Python</li></ol><pre>pip install selenium</pre><h3>Step 1: Prepare Your CSV File</h3><p>Create a file named contacts.csv in the same directory as your script. It should look like this:</p><pre>Number,Name<br>1234567890,John Doe<br>9876543210,Jane Smith</pre><p>Ensure the <strong>Phone</strong> column contains the full phone number including the country code, without any + or spaces.</p><h3>Step 2: Read CSV File Script</h3><p>Read contacts phone number and name</p><pre>def read_contacts_from_csv(csv_file):<br>    contacts = []<br>    try:<br>        with open(csv_file, mode=&quot;r&quot;, encoding=&quot;utf-8&quot;) as file:<br>            reader = csv.DictReader(file) <br>            for row in reader:<br>                phone_number = row[&quot;Number&quot;]<br>                name = row[&quot;Name&quot;]   <br>                contacts.append({&quot;name&quot;: name, &quot;phone_number&quot;: phone_number})<br>    except Exception as e:<br>        print(f&quot;Error reading CSV file: {e}&quot;)<br>    return contacts</pre><h3>Step 3: <strong>Sending a WhatsApp Message</strong></h3><p>The function opens WhatsApp Web for a contact’s phone number, waits for the chat to load, enters the message in the chat box, and clicks the send button.</p><pre>def send_whatsapp_message(driver, contact, message, success_counter):<br>    try:<br>        driver.get(f&quot;https://web.whatsapp.com/send?phone={contact}&quot;)<br>        print(f&quot;Opening chat for {contact}...&quot;)<br>        WebDriverWait(driver, 15).until(<br>            EC.presence_of_element_located((By.XPATH, &quot;//*[@id=&#39;main&#39;]//header&quot;))<br>        )<br>        print(&quot;Chat loaded...&quot;)<br><br>        message_box = WebDriverWait(driver, 10).until(<br>            EC.presence_of_element_located((By.XPATH, &quot;//*[@id=&#39;main&#39;]/footer/div[1]/div/span/div/div[2]/div[1]/div[2]/div[1]/p&quot;))<br>        )<br>        driver.execute_script(&quot;arguments[0].scrollIntoView(true);&quot;, message_box)<br>        message_box.click()<br>        message_box.send_keys(message)<br>        print(f&quot;Message &#39;{message}&#39; typed...&quot;)<br><br>        send_button = WebDriverWait(driver, 20).until(<br>            EC.element_to_be_clickable((By.XPATH, &quot;//*[@id=&#39;main&#39;]/footer/div[1]/div/span/div/div[2]/div[2]/button&quot;))<br>        )<br>        send_button.click()<br>        success_counter[0] += 1<br>        print(&quot;Message sent successfully!&quot;)<br><br>    except Exception as e:<br>        print(f&quot;An error occurred: {e}&quot;)<br>    finally:<br>        time.sleep(15)</pre><p>You can get <em>XPATH</em> of elements such as message box or send button by inspecting the elements in <strong>Google Chrome</strong> or any browser. Right-click on the element, choose <strong>Inspect</strong>, and then right-click on the highlighted element in the browser’s developer tools. Select <strong>Copy &gt; Copy XPath</strong> to get the XPath for the element.</p><h3>Step 4: Combining it all into main function</h3><p>In the main function, we set up the Selenium WebDriver, read contacts from the CSV file, and send personalized messages to each contact.</p><pre>def main():<br>    contacts = read_contacts_from_csv(&quot;/path/to/contacts.csv&quot;)<br>    driver = webdriver.Chrome(service=Service(&quot;/path/to/chromedriver&quot;))<br><br>    driver.get(&quot;https://web.whatsapp.com&quot;)<br>    print(&quot;Scan the QR code in your phone to log in.&quot;)<br>    WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, &quot;//div[@contenteditable=&#39;true&#39;][@data-tab=&#39;3&#39;]&quot;)))<br><br>    message_template = &quot;Hello {name}, this is a test message!&quot;<br>    success_counter = [0]<br><br>    for contact in contacts:<br>        message = message_template.format(name=contact[&quot;name&quot;])<br>        send_whatsapp_message(driver, contact[&quot;phone_number&quot;], message, success_counter)<br><br>    print(f&quot;Total messages sent: {success_counter[0]}&quot;)<br>    driver.quit()</pre><h3>Important Notes</h3><ol><li><strong>Use Responsibly</strong>: Automating WhatsApp messages should comply with WhatsApp’s terms of service and privacy guidelines.</li><li><strong>Rate Limiting</strong>: Avoid sending too many messages too quickly to prevent being flagged as spam.</li><li><strong>CAPTCHA or Anti-Bot Mechanisms</strong>: This script may not work if WhatsApp introduces mechanisms to detect bots.</li></ol><h3>Conclusion</h3><p>Automating WhatsApp messages with Selenium can streamline repetitive communication tasks. By integrating ChromeDriver and reading from CSV files, you can send personalized messages to multiple contacts effortlessly. While this script provides a foundation, you can extend its functionality to handle advanced use cases like sending attachments or responding to messages dynamically.</p><p>Happy automating!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cef44c63cf5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to run GAP models in a web application?]]></title>
            <link>https://medium.com/@wala.saiif/how-to-run-gap-models-in-a-web-application-3c8375ed2281?source=rss-26033edd4440------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c8375ed2281</guid>
            <category><![CDATA[openserver]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[gap]]></category>
            <category><![CDATA[petroleum]]></category>
            <category><![CDATA[petroleum-engineering]]></category>
            <dc:creator><![CDATA[Wala Al Ramadhani]]></dc:creator>
            <pubDate>Sat, 09 Nov 2024 15:39:21 GMT</pubDate>
            <atom:updated>2024-11-09T15:39:21.933Z</atom:updated>
            <content:encoded><![CDATA[<p>GAP is a powerful petroleum engineering software used to model and optimize oil and gas production systems. With Python and the Open Server API, you can seamlessly integrate GAP models into web applications, enabling real-time data access and control from anywhere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hM_l7ntH5mr4cYvi" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong>Why build a Web App to run GAP Models?</strong></h3><ul><li><strong>Accessibility</strong>: Engineers and operators can run models on any device with a browser without needing to install GAP on their machine.</li><li><strong>Centralization</strong>: All team members work from the same model version, reducing discrepancies.</li><li><strong>Cost Savings</strong>: Only one GAP license is needed on the hosting server, reducing licensing costs for teams.</li></ul><h3>Prerequisites</h3><p>Before getting started, ensure that you have:</p><ol><li><strong>GAP Software</strong> installed on a machine (preferably a server) that supports Open Server.</li><li><strong>Open Server</strong> license is configured and accessible.</li><li><strong>Python</strong> is installed, we’ll be using python to connect to a GAP model using Open Server</li></ol><h3>What is Open Server API?</h3><p>OpenServer is the Petex API Protocol that allows other softwares to interact with IPM engineering tools such as GAP, MBAL, and PROSPER, enabling the automation of data inputs and running model calculations.</p><h3>Step 1: Install required packages</h3><p>Install below packages required to interact with GAP.</p><pre>pip install openserver<br>pip install pywin32</pre><ul><li>openserver provides functions and classes specifically designed to help interact with Petex softwares</li><li>pywin32allows Python to communicate with other Windows programs, making it possible for Python to send commands to Petex softwares and other Windows applications.</li></ul><h3>Step 2: Connecting to OpenServer</h3><p>Once the packages are installed, you’ll need to create a Python class to manage connections with OpenServer.</p><pre>from openserver import OpenServer<br>import win32com.client<br><br>class Open_Server():<br>    def __init__(self):<br>        self.OSReference = None<br>        self.status = &quot;Disconnected&quot;<br>        <br>    def Connect(self):<br>        self.OSReference = win32com.client.Dispatch(&quot;PX32.OpenServer.1&quot;)<br>        self.status = &quot;Connected&quot;<br>        <br>    def Disconnect(self):<br>        self.OSReference = None<br>        self.status = &quot;Disconnected&quot;<br></pre><h3>Step 3: Interacting with GAP</h3><p>Before running calculations or solving the model, you’ll want to interact with it — setting values, retrieving results, or executing commands. These functions outline how to do that.</p><ol><li><strong>DoCmd</strong> — sends specific commands to the GAP model, triggering operations like running simulations or calculations.</li><li><strong>DoSet</strong> — allows you to set specific values or parameters in the GAP model.</li><li><strong>DoGet</strong> — returns values or results from GAP model.</li></ol><pre># execute a command<br>def DoCmd(self, cmd):<br>    lerr = self.OSReference.DoCommand(cmd)<br>    if lerr &gt; 0:<br>        err = self.OSReference.GetErrorDescription(lerr)<br>        self.Disconnect()<br>        sys.exit(&quot;DoCmd: &quot; + err)<br><br># set value in the model<br>def DoSet(self, sv, val):<br>    lerr = self.OSReference.SetValue(sv, val)<br>    app_name = self.GetAppName(sv)<br>    lerr = self.OSReference.GetLastError(app_name)<br>    if lerr &gt; 0:<br>        err = self.OSReference.GetErrorDescription(lerr)<br>        self.Disconnect()<br>        sys.exit(&quot;DoSet: &quot; + err)<br><br># get value from model<br>def DoGet(self, gv):<br>    value = self.OSReference.GetValue(gv)<br>    app_name = self.GetAppName(gv)<br>    lerr = self.OSReference.GetLastError(app_name)<br>    if lerr &gt; 0:<br>        err = self.OSReference.GetErrorDescription(lerr)<br>        self.Disconnect()<br>        sys.exit(&quot;DoGet: &quot; + err)<br>    return value<br><br># get app name from string<br>def GetAppName(self, strval):<br>    return strval.split(&#39;.&#39;)[0]   </pre><h3>Step 4: Running GAP Models</h3><p>Now that we have the connection and essential functions set up, you can run the GAP model. This can be done by issuing commands to OpenServer, which will be sent to GAP.</p><ol><li><strong>Opening a GAP Model</strong> — This function will load a specific GAP model file for use.</li><li><strong>Solving a GAP Model</strong> — This function triggers the model to solve and run the necessary calculations.</li><li><strong>Closing the GAP Model</strong> — After the model is solved, you can close the GAP application and disconnect from OpenServer.</li></ol><pre>def OpenGAP(GAP_model_path):<br>    c = OpenServer()<br>    c.connect<br>    c.DoCmd(&#39;GAP.START&#39;) # Start the GAP application<br>    c.DoCmd(&#39;GAP.OPENFILE(&quot;&#39;+ GAP_model_path +&#39;&quot;)&#39;) # Open the model file<br>    c.disconnect()<br><br>def SolveGAP(self):<br>    DoGAPFunc(self, &quot;GAP.OSMONITOR(0)&quot;) # Monitor the model&#39;s status<br>    DoGAPFunc(self, &quot;GAP.SOLVENETWORK(0)&quot;) # Solve the model&#39;s network<br><br>def CloseGAP():<br>    c = OpenServer()<br>    c.connect()<br>    c.DoCmd(&quot;GAP.SHUTDOWN&quot;) # Shut down GAP application<br>    c.disconnect()<br><br># Executes a GAP command and retrieves the result<br>def DoGAPFunc(self, value):<br>    DoCmd(self, value) # Execute the GAP command<br>    result = DoGet(self, &quot;GAP.LASTCMDRET&quot;) # Retrieve the result of the last command<br>    lerr = self.OSReference.GetLastError(&quot;GAP&quot;) <br>    if lerr &gt; 0:<br>        err = self.OSReference.GetErrorDescription(lerr)<br>        self.Disconnect()<br>        sys.exit(&quot;DoGAPFunc: &quot; + err)<br>    return result</pre><h3>Additional Resources</h3><p>For general information on OpenServer and its functionality, refer to the official <a href="https://www.petex.com/pe-engineering/ipm-suite/openserver/#5454"><em>Petroleum Experts</em></a> site. And to learn more about using the OpenServer Python package specifically, check out the <a href="https://pypi.org/project/openserver/">PyPI OpenServer documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c8375ed2281" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to deploy Streamlit app to Windows?]]></title>
            <link>https://medium.com/@wala.saiif/how-to-deploy-streamlit-app-to-windows-iis-76226a8fbc3a?source=rss-26033edd4440------2</link>
            <guid isPermaLink="false">https://medium.com/p/76226a8fbc3a</guid>
            <dc:creator><![CDATA[Wala Al Ramadhani]]></dc:creator>
            <pubDate>Mon, 06 May 2024 16:57:39 GMT</pubDate>
            <atom:updated>2024-08-02T18:37:23.478Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>How to deploy Streamlit app to Windows Server?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OrIwNCGotUPudqQs" /><figcaption>Photo by <a href="https://unsplash.com/@hishahadat?utm_source=medium&amp;utm_medium=referral">Shahadat Rahman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>You can easily make use of windows task scheduler to run a streamlit app with a defined DNS</p><h3>1. Create Powershell script</h3><p>Save the below script as <em>(run.ps1)</em> under the same folder of your streamlit app</p><blockquote>Assuming that you’re using a virtual environment to run the app whose entry point is <strong><em>main.py</em></strong></blockquote><pre>Set-Location c:\path\to\app<br>.\venv\Scripts\activate.ps1<br>streamlit run main.py --browser.serverAddress &quot;example.com&quot;</pre><h3>2. Set up Task Scheduler</h3><ul><li>Create a new task</li><li>Add New Trigger (At Startup)</li><li>Add New Action<br>– <strong>Action: </strong>Start a program<br>– <strong>Program/script:</strong> c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe<br>– <strong>Add Arguments: </strong>-File c:\path\to\run.ps1</li></ul><h3>3. Test the setup</h3><p>You can first test the created script by running it through powershell ISE. It should return the url of the running app. And then you can test the created scheduler task by manually running it :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76226a8fbc3a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use OPENQUERY in SQL?]]></title>
            <link>https://medium.com/@wala.saiif/how-to-use-openquery-in-sql-695d59cd889?source=rss-26033edd4440------2</link>
            <guid isPermaLink="false">https://medium.com/p/695d59cd889</guid>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[query]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Wala Al Ramadhani]]></dc:creator>
            <pubDate>Sun, 22 May 2022 17:21:25 GMT</pubDate>
            <atom:updated>2022-05-22T17:40:10.516Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gz-7BR0YOBWf5pYc" /><figcaption>Photo by <a href="https://unsplash.com/@casparrubin?utm_source=medium&amp;utm_medium=referral">Caspar Camille Rubin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><strong>What is OPENQUERY?</strong></h4><p>A command used to execute queries within a linked server. For example it can be used to access a table in Oracle within SQL Database.</p><pre>OPENQUERY (linked_server ,&#39;query&#39;)</pre><h4><strong>SELECT statement</strong></h4><pre>SELECT * FROM OPENQUERY(linked_server,<br>&#39;SELECT title from Books WHERE title like &#39;&#39;name%&#39;&#39; &#39;);</pre><p>Data from <em>openquery</em> can also be joined with other tables within the server, for example:</p><pre>SELECT * FROM OPENQUERY(linked_server,&#39;SELECT * from Books&#39;) B<br>LEFT JOIN Authors A on A.id = B.authorId<br>WHERE A.name like &#39;A%&#39;;</pre><h4>INSERT statement</h4><pre>INSERT OPENQUERY(linked_server,&#39;SELECT title,authorId from Books&#39;)<br>VALUES(&#39;BookTitle&#39;,3);</pre><h4><strong>UPDATE statement</strong></h4><pre>UPDATE OPENQUERY(linked_server,&#39;SELECT genre from Books <br>where title = &#39;&#39;BookTitle&#39;&#39; &#39;)<br>SET genre = &#39;Genre&#39;;</pre><h4>DELETE statement</h4><pre>DELETE OPENQUERY(linked_server,&#39;SELECT * from Books <br>where title = &#39;&#39;BookTitle&#39;&#39; &#39;)</pre><p>Delete conditions can also be combined with tables within the server, for example:</p><pre>DELETE FROM OPENQUERY(linked_server,&#39;SELECT * from Books&#39;)<br>WHERE author_id in <br>(select id from Authors where WHERE name like &#39;A%&#39;)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=695d59cd889" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>