### 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.

### Actions

- **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.

#### Code Action…

```javascript
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\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

- **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
    ```

### 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

#### Example function

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

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

### Dependencies

- **camelcase** 8.0.0
- **googleapis** 133.0.0

### Configuration

- **Gmail**
- **OAuth**
