> For the complete documentation index, see [llms.txt](https://developer.emporix.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.emporix.io/agentic-commerce-intelligence/agentic-intelligence/agent-library/cloud-function-agent.md).

# Cloud Function Assistant

The Cloud Function Assistant generates and edits deployable HTTP Cloud Functions from a natural-language request in Hosting.

The **Cloud Function Assistant** is a configuration helper agent for the Hosting management experience. It generates and edits deployable HTTP Cloud Functions for Node.js and Python from a natural-language request in the **New Deployment** dialog.

Unlike workflow agents that run in production to handle business processes, the Cloud Function Assistant supports Cloud Function setup. It reduces the need to start from a blank archive when you deploy custom logic to [Emporix Hosting](/user-guides/management-dashboard/administration/hosting.md).

## Purpose

The agent's purpose is to implement your latest instruction against the current Cloud Function workspace. It updates the deployable source so the function can be built and hosted. Use it when you want a starting implementation, or when you want to adjust an existing function without uploading a new archive.

The assistant keeps the workspace as a Cloud Function package. It does not add frontend or Management Dashboard extension code unless you explicitly ask for it.

## Key benefits

Once you enable the assistant, it is available when you choose **AI Cloud Function** as the deployment source in **Administration** -> **Hosting**. Describe the change, then review the generated files before you deploy.

| Benefit                                  | Description                                                                                                                                  |
| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| **Natural-language function setup**      | Describe what you want the function to do instead of writing the first version of the ZIP by hand.                                           |
| **Deployable Node.js and Python output** | The assistant follows the runtime already in the workspace and produces an HTTP entry point that Hosting can build.                          |
| **Available in New Deployment**          | Use the assistant directly in the **AI assistant** tab, then inspect the result in the **Code** tab.                                         |
| **Platform identity reuse**              | Generated functions read Emporix-injected request headers for outbound API calls instead of embedding tokens or tenant values in the source. |

## How it works

After you create a Cloud Function with a name and runtime, choose **New Deployment** and select **AI Cloud Function**. In the **AI assistant** tab, describe in natural language what the function is for and how you want it to work. The assistant uses that description, together with the runtime you already selected, to generate the function source.

It then:

* Follows the selected runtime: Node.js (`package.json` / `index.js`) or Python (`requirements.txt` / `main.py`). It does not mix runtimes or convert them unless you ask.
* Implements the request as an HTTP Cloud Function with the `main` entry point, using the Functions Framework for that runtime.
* Keeps dependency manifests in sync with the source. When it changes JavaScript files, it also updates `package.json`. When it changes Python files, it also updates `requirements.txt`.
* Leaves binary files unchanged and returns only the text files it created or modified.
* Does not add secrets, `.env` files, or lockfiles to the ZIP. Environment variables stay in the Hosting **Environment variables** UI.

When the function calls an upstream HTTP API, the default behavior is to forward the same status code and response body. The assistant uses the invocation headers supplied by Emporix, such as `emporix-token` and `emporix-tenant`, for outbound Emporix API calls. It does not add extra JWT or login checks unless you ask. See [Cloud Function context for dynamic MCP tools](/agentic-commerce-intelligence/agentic-intelligence/configuration/custom-mcp.md#cloud-function-context-for-dynamic-mcp-tools) for how those headers are set when you use the function as a dynamic MCP tool.

After the assistant responds, open the **Code** tab to review the files, then choose **Deploy**.

{% hint style="info" %}
The assistant is suited to straightforward Cloud Functions. For more complex logic, review and extend the generated code before you deploy.
{% endhint %}

### Trigger

{% hint style="info" %}
The Cloud Function Assistant is listed in **Predefined Agents** from the start, so you can enable it from the [AI Agent Library](/agentic-commerce-intelligence/agentic-intelligence/agent-library.md) at any time.

If the assistant is not enabled yet, the first time you select **AI Cloud Function** in **New Deployment**, you are prompted to enable it. Select **Enable Cloud Function Assistant** to create it from the predefined template. You need the `ai.agent_manage` permission. After that, it is available in the **AI assistant** tab.

For the Hosting deploy flow, see [Host a cloud function](/user-guides/management-dashboard/administration/hosting.md#host-a-cloud-function).
{% endhint %}

## Agent configuration

Once you enable the Cloud Function Assistant from the dedicated template, you can adjust its configuration in the Agents Library like other predefined agents.

### User prompt

The default prompt instructs the assistant to implement the latest user request against the current workspace snapshot and to return only the files it created or changed. It is optimized for deployable HTTP Cloud Functions: a `main` entry point, runtime-accurate dependency files, reuse of Emporix request headers for outbound calls, and passthrough of upstream API responses unless you ask for a different shape.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.emporix.io/agentic-commerce-intelligence/agentic-intelligence/agent-library/cloud-function-agent.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
