How to Create "Agents" to Automate Your Dull Work

in developers •  last month

    image.png

    "Agents" are a popular buzzword right now but the concept has been around for a long time. I don't think it is a coincidence that there were agents in the Matrix movies that served double definitions of the word!

    What are agents?

    An agent is a program that can perform tasks for you, autonomously or semi-autonomously. While it is not necessary for your agent to have "intelligence" (just instructions or simple logic is sufficient in most cases), AI agents promise to collect data about their performance and then use that feedback to learn and improve over time.

    It goes like this:

    1. Accept instructions
    2. Collect data
    3. Make decisions
    4. ???
    5. Learn
    6. Improve

    The last two are optional but are the main promise of using AI in the mix. A secondary benefit, of course, is cutting programmers out of the workflow. We're not really there fully yet but maybe soon.

    What happens in point 3 depends on your goal, and again you'll be surprised how often AI is not needed.

    A lot of services require API access, for example working with Hive or other secure transactions, but even for simple things like checking the weather.

    But what if the service doesn't have an API, or the API is too pricey or restrictive?

    There are also a lot of tasks that we do on a day-to-day basis that only require text internet access.

    For example, a lot of my most impressive automation is simply Python, Selenium, and some logic.

    Today I impressed a client by scraping LinkedIn. This is not strictly within the terms of service but all I was doing was taking the copy-and-paste effort out and replacing it with a bot that I was observing.

    image.png

    Using my own cookies (exported using the Chrome extension linked above) I was using my own credentials, so I do not advise sharing this even on Github, but the work produced saved thousands in VA fees.

    In Python you can add your known cookie values using a variation on the below code:

                        cookie = {
                            'domain': fields[0],
                            'flag': fields[1],
                            'path': fields[2],
                            'secure': fields[3],
                            'expiration': fields[4],
                            'name': fields[5],
                            'value': fields[6]
                        }
                        browser.add_cookie({
                            'name': cookie['name'],
                            'value': cookie['value'],
                            'domain': cookie['domain'],
                            'path': cookie['path'],
                            'expiry': int(cookie['expiration']) if cookie['expiration'] else None
                        })
    

    Think how often you do things in a web browser that could be automated, on a schedule or in reaction to an external event?

    How do you react to something happening? You put your script on a web server and then use Make.com, IFTTT, or Zapier webhooks to call your script!

      Authors get paid when people like you upvote their post.
      If you enjoyed what you read here, create your account today and start earning FREE VOILK!