Skip to main content
Version: 2.3

Call actor

This example demonstrates how to start an Apify actor using and how to call the Apify API using Apify.client. The script gets a random weird word and its explanation from and sends it to your email using the apify/send-mail actor.

To make the example work, you'll need an Apify account. Go to the Account - Integrations page to obtain your API token and set it to the APIFY_TOKEN environment variable, or run the script using the Apify CLI. If you deploy this actor to the Apify Cloud, you can do things like set up a scheduler to run your actor early in the morning.

To see what other actors are available, visit the Apify Store.

To run this example on the Apify Platform, select the Node.js 12 + Chrome on Debian (apify/actor-node-chrome) base image on the Source tab when configuring the actor.

const { Actor } = require('apify');
const { launchPuppeteer } = require('crawlee');

Actor.main(async () => {
// Launch the web browser.
const browser = await launchPuppeteer();

console.log('Obtaining own email address...');
const apifyClient = Actor.newClient();
const user = await apifyClient.user().get();

// Load and get a random word
console.log('Fetching a random word.');
const page = await browser.newPage();
await page.goto('');
const randomWord = await page.$eval('#shared_section', (el) => el.outerHTML);

// Send random word to your email. For that, you can use an actor we already
// have available on the platform under the name: apify/send-mail.
// The second parameter to the invocation is the actor's
// desired input. You can find the required input parameters by checking
// the actor's documentation page:
console.log(`Sending email to ${}...`);
await'apify/send-mail', {
subject: 'Random Word',
html: `<h1>Random Word</h1>${randomWord}`,
console.log('Email sent. Good luck!');

// Close Browser
await browser.close();