Skip to main content

How to vibe code Cloud Functions

Distributor steps to build Encompass Cloud Functions (C# on AWS Lambda) with AI using Local Edit and VS Code with GitHub Copilot: compile, Push To Lambda, test. Needs API Edit permission and v26.03+.

B
Written by Bailey Naas-Thornton

Minimum Version Required: 26.03

Pre-Conditions

Before You Begin

Welcome! You're about to learn how to build custom back-end features for Encompass using AI — no prior coding experience required. Here's what you need to have ready before starting.

What You Need

  1. An Encompass account with permission to edit Cloud Functions - API Edit permission, and a Solution Authentication for that Application/Solution (ask your admin if unsure)

  2. A GitHub account (free) — needed for GitHub Copilot, the AI assistant that will write code for you

  3. A GitHub Copilot subscription — there is a free tier available at github.com/features/copilot — Note that the free tier will have lower usage limits and limit to less intelligent AI models

What You Should Know

You do not need to know how to code. The whole point of "vibe coding" is that you describe what you want in plain English, and the AI writes the code for you. However, it helps to understand these basics:

  • Cloud Functions are custom C# code blocks that run on the server. They let you extend Encompass with custom logic — like sending emails, processing data, or connecting to external services.

  • The browser editor inside Encompass is where your code lives. It handles compiling (checking for errors) and deploying (making it live).

  • Local Edit is the feature that downloads your code to your computer so an AI coding tool can work on it. Changes sync back to the browser automatically.

  • You will not compile code on your computer. The browser editor does that for you.

What is "Vibe Coding"?

Vibe coding means describing what you want to build in plain language and letting an AI assistant generate the code. You guide the direction, review the results, and iterate. Think of it like having a conversation with a developer who works instantly.

Alternative AI Editors

This guide focuses on VS Code + GitHub Copilot, but the Local Edit feature works with any editor. Popular alternatives include:

  • Cursor — an AI-native editor built on VS Code (cursor.com)

  • Windsurf — another AI-powered editor (windsurf.com)

If you choose one of these, skip the VS Code installation steps and follow that editor's own setup guide. The Encompass workflow remains the same.

Steps

Step-by-Step Setup & Workflow

Part 1: Install Your Tools

Step 1 — Install VS Code

  1. Go to code.visualstudio.com and download the installer for your operating system.

  2. Run the installer and follow the prompts. The defaults are fine.

  3. Open VS Code once it's installed.

Using Cursor or Windsurf instead? Download from their respective websites and open the app. Both have built-in AI features, so you can skip the Copilot extension step below — but still install the C# extension.

Step 2 — Install the C# Extension

This gives you syntax highlighting and basic language support for C# files. You won't compile locally, but this makes the code much easier to read and work with.

  1. In VS Code, click the Extensions icon in the left sidebar (it looks like four squares).

  2. Search for "C#" in the search bar.

  3. Find the extension called "C# Dev Kit" by Microsoft and click Install.

  4. This will also install the base "C#" extension automatically.

In Cursor/Windsurf: the same extension is available in their extension marketplaces. Search for "C# Dev Kit" and install it.

Step 3 — Install GitHub Copilot

  1. In the VS Code Extensions sidebar, search for "GitHub Copilot".

  2. Install the extension called "GitHub Copilot" by GitHub.

  3. You will also want to install "GitHub Copilot Chat" — this gives you the chat panel where you can have conversations with the AI.

  4. After installing, click Sign in to GitHub when prompted, and sign in with your GitHub account.

  5. If you haven't set up Copilot on your GitHub account yet, you'll be prompted to activate it (a free tier is available).

Cursor and Windsurf have their own built-in AI, so you don't need Copilot with those editors. They will prompt you to sign in to their respective services.


Part 2: Open a Cloud Function for Local Editing

Step 4 — Navigate to Cloud Functions

  1. In Encompass, navigate to the Cloud Function you want to work on (or create a new one). This is found on the API Commands table, clicking the 'Edit Code' icon on the left side.

  2. The Cloud Function editor will open in your browser with the C# code editor.

Step 5 — Enable Local Edit

  1. In the Cloud Function editor, look for the Local Edit option.

  2. Click it to download the code files to a local folder on your computer.

  3. Note the folder location — you'll need to open it in VS Code.

  4. Keep the browser tab open! The browser needs to stay open to sync your changes back and to compile/deploy your code.

Step 6 — Open the Folder in VS Code

  1. In VS Code, go to File → Open Folder.

  2. Navigate to the folder where your Cloud Function files were downloaded.

  3. Click Open. You'll see your C# file(s) in the file explorer on the left.


Part 3: Vibe Code Your Cloud Function

Step 7 — Open Copilot Chat

  1. Open the Copilot Chat panel — click the chat icon in the left sidebar, or press Ctrl+Shift+I (Windows/Linux) or Cmd+Shift+I (Mac).

  2. In the newer version, you may also use the Agent Mode to have Copilot edit files directly. Select "Agent" from the mode dropdown at the top of the chat panel.

In Cursor: Press Ctrl+L (or Cmd+L on Mac) to open the AI chat. In Windsurf: Look for the Cascade panel on the right side.

Step 8 — Describe What You Want

This is the fun part. Tell the AI what you want your Cloud Function to do, in plain English. Here are some example prompts to get you started:

"I want this function to take an email address as a parameter, look up the customer in our system using the Encompass SDK, and return their account balance as a JSON string."

"Make this function send a notification email when called. Use the parameters to get the recipient email and the message body."

"Add a new parameter called OrderID to the Parameters class, then use the Encompass SDK to look up that order and return its status."

The AI will generate C# code and insert it into your file. You can keep chatting to refine it — ask it to fix things, add features, or explain what it wrote.

Step 9 — Understand the Code Structure

Every Cloud Function has a specific structure that must not be changed. The AI should respect this, but it's good to know:

namespace YourFunctionName — must match your API Command name{ public class Function — the class name can't change { public string FunctionHandler(Parameters myParameters, ILambdaContext context) — this is the entry point; the name and parameters can't change { // YOUR CODE GOES HERE // Use myParameters.EncompassID, myParameters.Email, etc. return "result string"; } } public class Parameters — add custom parameters here { public string EncompassID { get; set; } public string EncompassSessionID { get; set; } public string EncompassDBServer { get; set; } public string Email { get; set; } // Add your own parameters below: // public string OrderID { get; set; } }}

Key rule: Don't change the namespace name, the class name "Function", or the FunctionHandler method signature. You can add custom parameters to the Parameters class and add helper methods below the entry function.

Step 10 — Save and Let It Sync

  1. Save your file in VS Code (Ctrl+S / Cmd+S).

  2. The Local Edit feature will automatically sync your changes back to the browser editor.


Part 4: Compile, Test & Deploy

Step 11 — Compile in the Browser

  1. Go back to the Encompass browser tab (keep it open the whole time).

  2. Click the Compile button in the toolbar.

  3. The console at the bottom will show either a success message or error details.

  4. If there are errors, go back to VS Code and ask the AI to fix them. Paste the error message into chat:

    "I got this compile error: [paste error here]. Please fix it."

  5. Save, sync, compile again. Repeat until it succeeds.

Step 12 — Push to Lambda

  1. Once compilation succeeds, click Push To Lambda in the toolbar.

  2. This deploys your function to AWS Lambda and makes it available as an API endpoint.

  3. The first push may take a moment. You'll see a success message when it's done.

Step 13 — Run a Test

  1. After pushing, the Run Test button becomes active.

  2. Click Run Test. A dialog will appear with a JSON input field:

{ "key1": "value1", "key2": "value2"}
  1. Replace the sample values with real test data that matches your Parameters (e.g., an actual email address or order ID). If it helps, you can also ask the AI back in the editor to help you figure out how to format this.

  2. Click Run and check the console output to see if your function works as expected.

Step 14 — Iterate and Improve

This is the vibe coding loop:

  1. Describe what you want → AI writes code

  2. Save → changes sync to browser

  3. Compile → fix errors with AI help

  4. Push & Test → verify it works

  5. Repeat — refine, add features, keep going

Each cycle gets faster once you get the hang of it. Don't be afraid to experiment — the Compile step catches mistakes before anything goes live.


Part 5: Using the Encompass SDK

The Cloud Function editor has an Encompass SDK tab that documents all the helper classes and methods available to you inside Cloud Functions. These are pre-built tools for things like:

  • Making HTTP requests (BC_HttpRequest)

  • Working with data (BC_Fmt)

  • Encrypting/decrypting values (BC_Fmt.AES_Encrypt, BC_Fmt.AES_Decrypt)

  • And more — check the SDK tab for the full list

When chatting with the AI, mention that you want to use the Encompass SDK. You can even paste snippets from the SDK tab into the chat so the AI knows what's available. For example:

"Use the BC_HttpRequest class from the Encompass SDK to make a GET request to this URL and return the response."


Part 6: Using Environment Variables

Environment variables let you store secrets (API keys, passwords, tokens) and configuration values safely outside your code. They are stored securely on the Lambda function itself and are never exposed in the code editor or version history.

1. Open the Environment Variables Dialog

In the Cloud Function editor toolbar, click the Environment variables button.

A dialog will open showing any existing variables. Existing values are masked as *** for security.

2. Add, Edit, or Remove Variables

To add a variable: select Add variable at the bottom of the dialog. Enter a unique key name and a value.

To edit a variable: Type a new value in the Value field. If you leave the value as ***, the existing value is kept unchanged.

To remove a variable: select the delete icon next to the row you want to remove.

When finished, select Save changes. Each key must be unique — duplicate keys are not allowed.

3. Access Environment Variables in Your Code

In your C# Cloud Function, read environment variables using the standard .NET method:

string myApiKey = System.Environment.GetEnvironmentVariable("MY_API_KEY");

Or as a static value at the top of the file:

private static readonly string myApiKey = System.Environment.GetEnvironmentVariable("MY_API_KEY");

This keeps secrets out of your source code entirely. You can tell the AI assistant:

"Store the API key in an environment variable called MY_API_KEY, and read it using System.Environment.GetEnvironmentVariable in the function."


Part 7: Saving Your Work

  • Save — saves your code to the Encompass system (does not deploy)

  • Save With Message — saves with a description of what you changed (like a commit message)

  • Compile — checks for errors without deploying

  • Push To Lambda — saves, compiles, and deploys your function live

Get into the habit of using Save With Message periodically so you have a history of what changed and why.

Fields And Definitions

Key Terms & Definitions

Term

Definition

Cloud Function

A custom C# code block that runs on AWS Lambda. It extends Encompass with custom server-side logic and connects to an API endpoint automatically.

Local Edit

A feature that downloads your Cloud Function code to a local folder on your computer, allowing you to edit it with VS Code or another editor. Changes sync back to the browser automatically.

Vibe Coding

A style of development where you describe what you want in natural language and an AI assistant writes the code for you. You guide, review, and iterate.

VS Code

Visual Studio Code — a free code editor from Microsoft. Used as the local editor for working with Cloud Function files.

GitHub Copilot

An AI coding assistant from GitHub that integrates into VS Code. It can generate, edit, and explain code based on natural language descriptions. Offers a free tier.

Agent Mode

A Copilot Chat mode that lets the AI read, edit, and create files directly — rather than just suggesting code snippets. Select it from the mode dropdown in the chat panel.

C# Dev Kit

A VS Code extension that provides syntax highlighting, IntelliSense, and basic language support for C# files. You don't need the full .NET SDK — this is just for editing comfort.

FunctionHandler

The entry point method of your Cloud Function. This is the method that runs when your API endpoint is called. Its name and parameters cannot be changed.

Parameters Class

A C# class that defines the input data your function receives. It always includes EncompassID, EncompassSessionID, EncompassDBServer, and Email. You can add your own custom parameters.

Compile

The process of checking your code for errors. Done in the browser — not locally. Click the Compile button to check before deploying.

Push To Lambda

Deploys your compiled code to AWS Lambda, making it live and accessible as an API endpoint in Encompass.

Run Test

Sends a test request to your deployed function with sample JSON data so you can verify it works correctly before connecting it to other parts of the system.

Encompass SDK

A library of pre-built helper classes available inside Cloud Functions (e.g., BC_HttpRequest, BC_Fmt). Documented in the SDK tab of the Cloud Function editor.

Environment Variables

Secure key-value pairs stored on the Lambda function. Used to keep secrets like API keys and passwords out of your code. Managed through the Environment variables button in the Cloud Function editor toolbar, and accessed in C# code with System.Environment.GetEnvironmentVariable().

Cursor / Windsurf

Alternative AI-powered code editors. They work with Local Edit just like VS Code but have their own built-in AI assistants instead of GitHub Copilot.

namespace

The top-level container for your code. It must match your API Command name exactly. Do not change it.

Best Practices

Best Practices

Talking to the AI

  • Be specific. Instead of "make it work better," say "add error handling so if the API call fails, return an error message with the status code."

  • Provide context. Tell the AI about the Encompass SDK. Paste SDK docs or class names into the chat so it knows what tools are available.

  • Iterate in small steps. Ask for one feature at a time. Get it compiling, then add the next thing. This makes errors much easier to fix.

  • Paste errors directly. When compile fails, copy the exact error message and paste it into the AI chat. It's very good at fixing compile errors when it can see the exact message.

Things to Never Change

  • The namespace name — it must match your API Command.

  • The class name "Function" — the system looks for this exact name.

  • The FunctionHandler method name and its parameters (Parameters myParameters, ILambdaContext context).

  • The LambdaSerializer assembly attribute at the top of the file.

  • If you accidentally change these, the AI can help fix them — tell it "restore the required structure for an Encompass Cloud Function."

Development Workflow Tips

  • Keep the browser tab open. Local Edit syncs through the browser — if you close it, the sync stops.

  • Compile often. Don't write 100 lines and then compile. Build in small increments so errors are easy to pinpoint.

  • Use Save With Message. Leave yourself notes about what changed. Future you (or a teammate) will thank you.

  • Test with realistic data. When using Run Test, provide parameter values that match real scenarios rather than generic "value1" placeholders.

  • Check the SDK tab. Before asking the AI to write custom code for something, check if the Encompass SDK already has a built-in method for it.

Security Notes

  • Never hardcode passwords, API keys, or secrets in your code. Use environment variables to store them securely (see Part 6).

  • To manage environment variables, select the Environment variables button in the toolbar. Values are encrypted and never visible in the code editor or version history.

  • Use the Encompass SDK's encryption methods (like BC_Fmt.AES_Encrypt) when handling sensitive data in transit or at rest.

  • The Parameters class automatically receives the authenticated user's EncompassID and session info — use those instead of passing credentials manually.

Getting Unstuck

  • If the AI generates code that won't compile, don't start over. Paste the error into chat and ask it to fix that specific issue.

  • If you're not sure what's possible, ask the AI: "What can I build with an Encompass Cloud Function that takes an email and order ID as parameters?"

  • Remember: compilation and deployment happen in the browser. If something isn't working locally, that's okay — the browser is the source of truth.

Did this answer your question?