Documentation

Actions

Overview

Lemni enables you to perform a wide range of actions through snippets of code that seamlessly integrate with your favorite apps and services. They usually require little setup. It’s plug & play! For extra convenience, relevant actions will be automatically recommended as you build your agent.

Actions consist of little snippets of JavaScript that often call an API. Your agent automatically provides it with the right information, and will receive the relevant response from the code snippet to continue.

Store

The store lets you browse and select community-made actions for your agents. They are available in the agent editor by default and can easily be used in 1-click.

Acme

Inbox

Assigned

Manage

Agents

Knowledge

Behavior

Actions

Settings

Tutorials

Learn the basics

Docs

Get the details ↗

Actions

Store

Search

Code Action…

Update Internal Dashboard

Send Email

Create Hubspot Company

Search Google

Send Slack Message

Update Notion Database

Read the documentation before you start building your own actions.

Browse actions that enable your Ai agents to use any service

Search 6 actions…

Create Hubspot Company

Use the Hubspot API to create a new CRM company in Hubspot.

Developer

Lemni

Installs

21.6k

Enrich Using Clearbit

Get info on a person or company based on email or domain.

Developer

Lemni

Installs

21.6k

Send Slack Message

Send Slack messages to any channel in your workspace.

Developer

Noud Adrichem

Installs

44.4k

Search Google

Browse the internet and use Google search results.

Developer

Krijn Rijshouwer

Installs

443

Send SMS

Send a text message to any phone number using Twilio.

Developer

Alex Buis

Installs

44

Get Notion Database

Use the Notion API to get data from a Notion database.

Developer

Lemni

Installs

4.6k

Send WhatsApp

Send a WhatsApp message to any phone number using Twilio.

Developer

Alex Buis

Installs

44

Create Hubspot Contact

Use the Hubspot API to create a new CRM contact in Hubspot.

Developer

Lemni

Installs

21.6k

Send Email

Send emails using your email address on GMail.

Developer

Acme

Installs

3.5k

Publishing your custom actions to the store is straightforward. No one will get access to the source code and the code will be stored in a completely secure environment. Start by clicking “+ Code Action…”, which will open the action editor. For detailed guidance on using the action editor, refer to the Code section in the actions documentation. Once your action is ready, deploy it and then click “Publish to Store” to share it with others. Our team will then check the code for safety and optionally add the verified badge.

Acme

Inbox

Assigned

Manage

Agents

Knowledge

Alignment

Actions

Settings

Tutorials

Learn the basics

Docs

Get the details ↗

Send Email

Dependencies

import { google } from "googleapis";

// the main function is the entrypoint.
export function main({ config }) {
    const oauth2Client = new google.auth.OAuth2();
    oauth2Client.setCredentials({ access_token: config["Google Gmail"].accessToken });
    const gmail = google.gmail({ version: "v1", auth: oauth2Client });

    return (async function () {
        let inbox = null;
        let foundThreadId = null;

        try {
            inbox = await gmail.users.messages.list({
                userId: "me",
                q: `from:${config["Email Address"]} subject:${config["Subject"]}`
            });

            if (inbox && inbox.data && inbox.data.messages && inbox.data.messages[0]) {
                foundThreadId = inbox.data.messages[0].threadId
            }
        } catch (err) { }

        const rawEmail = `To: ${config["Email Address"]}\r\nSubject: ${config["Subject"]}\r\n
${config["Email Text And Signature"]}`

        const newMessage = {
            raw: Buffer.from(rawEmail).toString("base64")
        }

        if (foundThreadId) {
            newMessage.threadId = foundThreadId;
        }

        try {
            const res = await gmail.users.messages.send({
                userId: "me",
                requestBody: newMessage
            });

            if (foundThreadId) {
                return {
                    response: `Email reply to ${config["Email Address"]} successfully sent.`
                };
            } else {
                return {
                    response: `Email to ${config["Email Address"]} successfully sent.`
                };
            }
        } catch (err) {
            return {
                response: JSON.stringify(`Error: ${err}`)
            };
        }
    })();
}

Configuration

Field…

Gmail

OAuth

Email Address

The email address to send the email to, e.g. john@gmail.com

Subject

The subject of the email, e.g. Hi there!

Email Text And Signature

The full email text and signature, e.g.

Hey John,


Thank you for reaching out. That sounds great! I will be in touch.


Kind regards,

Jane

Deploy

v1.0.0 · Updated 2d ago

Description

Use the Hubspot API to create a new CRM company in Hubspot.

Tags

Mail, Send, Gmail, Google

Instructions

  1. Connect your Google account.

  2. Provide an email address.

  3. Send the email.

Deployed

Publish to Store

Code

You can create your own actions by clicking “+ Code Action…” to open the code editor. You can switch between "Details" and "Code" at the top of the editor. Start by adding a name and description for the action, next write the code snippet needed to perform your action in the main function

This editor environment lets you write custom actions using JavaScript. We manage all the hosting and run the code in a secure server-side environment. All you need to do is return relevant text (ideally sanitised), which will automatically be added to the history and context.

Acme

Inbox

Assigned

Manage

Agents

Knowledge

Behavior

Actions

Settings

Tutorials

Learn the basics

Docs

Get the details ↗

Actions

Store

Search

Code Action…

Update Internal Dashboard

Send Email

Create Hubspot Company

Search Google

Send Slack Message

Update Notion Database

Read the documentation before you start building your own actions.

Send Email

Dependencies

import { google } from "googleapis";

// the main function is the entrypoint.
export function main({ config }) {
    const oauth2Client = new google.auth.OAuth2();
    oauth2Client.setCredentials({ access_token: config["Google Gmail"].accessToken });
    const gmail = google.gmail({ version: "v1", auth: oauth2Client });

    return (async function () {
        let inbox = null;
        let foundThreadId = null;

        try {
            inbox = await gmail.users.messages.list({
                userId: "me",
                q: `from:${config["Email Address"]} subject:${config["Subject"]}`
            });

            if (inbox && inbox.data && inbox.data.messages && inbox.data.messages[0]) {
                foundThreadId = inbox.data.messages[0].threadId
            }
        } catch (err) { }

        const rawEmail = `To: ${config["Email Address"]}\r\nSubject: ${config["Subject"]}\r\n
${config["Email Text And Signature"]}`

        const newMessage = {
            raw: Buffer.from(rawEmail).toString("base64")
        }

        if (foundThreadId) {
            newMessage.threadId = foundThreadId;
        }

        try {
            const res = await gmail.users.messages.send({
                userId: "me",
                requestBody: newMessage
            });

            if (foundThreadId) {
                return {
                    response: `Email reply to ${config["Email Address"]} successfully sent.`
                };
            } else {
                return {
                    response: `Email to ${config["Email Address"]} successfully sent.`
                };
            }
        } catch (err) {
            return {
                response: JSON.stringify(`Error: ${err}`)
            };
        }
    })();
}

Config

Gmail

OAuth

Email Address

Required

The email address to send the email to, e.g. john@gmail.com

Subject

Required

The subject of the email, e.g. Hi there!

Email Text And Signature

Required

The full email text and signature, e.g.

Hey John,


Thank you for reaching out. That sounds great! I will be in touch.


Kind regards,

Jane

Dependencies

camelcase

8.0.0

Install

googleapis

133.0.0

Deployed

Publish to Store

Private

v1.0.0

When an agent executes the action, the main function will be executed, returning context to Lemni. This allows the agent to use the data or get an idea of what went wrong (if something did go wrong).

// Example function
export function main({ config }) {
    console.log(config["Email"]);

    return {
        'response': 'Some relevant information'
    }; 
}

“Dependencies” in the top bar lets you install and use package dependencies in your code. Simply enter your package name and the version number and click install. Then import the package in your code.

Dependencies

camelcase

8.0.0

Install

@googleapis/gmail

12.0.0

Uninstall

The “Configuration” section on the right allows you to ask for values that our agent should provide based on the entire thread history and context. You can then easily access these values in your code. You can pick between OAuth providers, options, and text for the configuration fields.

The agent will automatically fill the fields with the relevant information from the context in the thread and the prompt. Make sure to name your configuration fields accordingly and provide accurate descriptions. This will improve the accuracy of the agent. Optionally make fields required if they always need to be filled and should never be empty.

Use the “config” parameter in the main function to access the values in the code. The OAuth values let you easily authenticate with existing services. These return a JSON object with an ‘accessToken’ and ‘account’.

Once it’s ready for use, click “Deploy” to publish your code to a secure server.

Acme

Inbox

Assigned

Manage

Agents

Knowledge

Alignment

Actions

Settings

Tutorials

Learn the basics

Docs

Get the details ↗

Send Email

Dependencies

import { google } from "googleapis";

// the main function is the entrypoint.
export function main({ config }) {
    const oauth2Client = new google.auth.OAuth2();
    oauth2Client.setCredentials({ access_token: config["Google Gmail"].accessToken });
    const gmail = google.gmail({ version: "v1", auth: oauth2Client });

    return (async function () {
        let inbox = null;
        let foundThreadId = null;

        try {
            inbox = await gmail.users.messages.list({
                userId: "me",
                q: `from:${config["Email Address"]} subject:${config["Subject"]}`
            });

            if (inbox && inbox.data && inbox.data.messages && inbox.data.messages[0]) {
                foundThreadId = inbox.data.messages[0].threadId
            }
        } catch (err) { }

        const rawEmail = `To: ${config["Email Address"]}\r\nSubject: ${config["Subject"]}\r\n
${config["Email Text And Signature"]}`

        const newMessage = {
            raw: Buffer.from(rawEmail).toString("base64")
        }

        if (foundThreadId) {
            newMessage.threadId = foundThreadId;
        }

        try {
            const res = await gmail.users.messages.send({
                userId: "me",
                requestBody: newMessage
            });

            if (foundThreadId) {
                return {
                    response: `Email reply to ${config["Email Address"]} successfully sent.`
                };
            } else {
                return {
                    response: `Email to ${config["Email Address"]} successfully sent.`
                };
            }
        } catch (err) {
            return {
                response: JSON.stringify(`Error: ${err}`)
            };
        }
    })();
}

Configuration

Field…

Gmail

OAuth

Email Address

The email address to send the email to, e.g. john@gmail.com

Subject

The subject of the email, e.g. Hi there!

Email Text And Signature

The full email text and signature, e.g.

Hey John,


Thank you for reaching out. That sounds great! I will be in touch.


Kind regards,

Jane

Deploy

v1.0.0 · Updated 2d ago

Description

Use the Hubspot API to create a new CRM company in Hubspot.

Tags

Mail, Send, Gmail, Google

Instructions

  1. Connect your Google account.

  2. Provide an email address.

  3. Send the email.

Deployed

Publish to Store

We’re bringing the personal touch back to customer interactions at scale

© 2025 Lemni BV