> For the complete documentation index, see [llms.txt](https://doc.aissist.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.aissist.io/integrations/aws-lambda.md).

# AWS Lambda

*Last updated: May 15, 2026*

Use AWS Lambda when you want Aissist to access internal systems through a controlled API layer.

This works well when you do not want to expose your database or backend systems directly.

With Lambda, you can:

* control exactly what data Aissist can read
* filter or transform the returned data
* expose only the fields and actions you want

### How the pattern works

1. Build a small Lambda function for the data or action you want to expose.
2. Publish it through a Function URL or API Gateway.
3. Connect that endpoint through the [RESTful API](/integrations/restful-api.md) integration.
4. Create actions that call the endpoint.

### Example flow

<details>

<summary>Step 1: write the Lambda function</summary>

Create a small function that returns only the data Aissist needs.

This example fetches booking details by booking ID:

```python
import mysql.connector

def lambda_handler(event, context):
    secrets = dict()
    with open("secrets.json") as input_fp:
        secrets = json.load(input_fp)
    
    database = mysql.connector.connect(
        host=secrets["host"],
        database=secrets["database"],
        user=secrets["user"],
        password=secrets["password"]
    )

    query = """ SELECT * FROM cr_booking WHERE id = %s """
    cursor = database.cursor()
    cursor.execute(query, (json.loads(event['body'])["booking_id"],))
    
    column_names = [col[0] for col in cursor.description]
    bookings = [dict(zip(column_names, row)) for row in cursor.fetchall()]
    
    return {"book_details": bookings}
```

</details>

<details>

<summary>Step 2: package the function</summary>

Package the function, dependencies, and any required configuration into a zip file.

1. Install the MySQL connector package:

   ```bash
   pip3 install --target ./packages mysql-connector
   ```
2. Create the deployment package:

   ```bash
   cd ./packages
   zip -r ../deployment_package.zip .
   cd ..
   zip deployment_package.zip lambda_function.py
   zip deployment_package.zip secrets.json
   ```

</details>

<details>

<summary>Step 3: create the Lambda function in AWS</summary>

1. Go to the **AWS Lambda Console**.
2. Create a new **Lambda function**.
3. Enable a **Function URL** for a simple setup, or use **API Gateway** for stricter control.
4. Upload your `deployment_package.zip`.
5. Copy the public endpoint URL.

<figure><img src="/files/PNJ5v891TqTRMxnhLLzr" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary>Step 4: connect Lambda to Aissist</summary>

Add the endpoint through the [RESTful API](/integrations/restful-api.md) integration.

Then create actions that call that endpoint.

Use the Lambda Function URL or API Gateway URL as the API endpoint.

</details>

### Why use AWS Lambda

AWS Lambda is useful because it is:

* **Secure** — expose only the data and operations you allow
* **Scalable** — no server management required
* **Cost-efficient** — pay only when it runs
* **Flexible** — shape the response for Aissist before it returns

### Best practice

Keep each Lambda endpoint focused on one job.

Return only the fields Aissist needs, then test the action in [Action Debugger](/integrations/action-debugger.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://doc.aissist.io/integrations/aws-lambda.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
