MultiOn: Twitter News Agent

In this example, we use Modal to deploy a cron job that periodically checks for AI news everyday and tweets it on Twitter using the MultiOn Agent API.

Import and define the app 

Let’s start off with imports, and defining a Modal app.

Searching for AI News 

Let’s also define an image that has the multion package installed, so we can query the API.

We can now define our main entrypoint, which uses MultiOn to scrape AI news everyday and post it on our Twitter account. We specify a schedule in the function decorator, which means that our function will run automatically at the given interval.

Set up MultiOn 

MultiOn is a Web Action Agent that can take actions on behalf of the user. You can watch it in action here.

The MultiOn API enables building the next level of web automation & custom AI agents capable of performing complex actions on the internet with just a few lines of code.

To get started, first create an account with MultiOn, install the MultiOn chrome extension and login to your Twitter account in your browser. To use the API, create a MultiOn API Key and store it as a Modal Secret on the dashboard

Test running 

We can now test run our scheduled function as follows: modal run multion_news_agent.py.py::app.news_tweet_agent

Defining the schedule and deploying 

Let’s define a function that will be called by Modal every day.

In order to deploy this as a persistent cron job, you can run modal deploy multion_news_agent.py.

Once the job is deployed, visit the apps page page to see its execution history, logs and other stats.