Skip to content

FiB3/ampscript-core

 
 

Repository files navigation

AMPscript Core

AMPscript Core is an open source implementation of the Marketing Cloud AMPscript language.

It is cross platform and works on Windows, macOS and Linux.

A VSCode plugin is available to edit, run and debug AMPscript files locally on your machine.

VSCode Plugin

Getting Started Using the VSCode Plugin

The VSCode plugin provides syntax highlighting and debugging capability for AMPscript files. The plugin supports files with a ".ampscript" extension.

It is not yet available on the VSCode marketplace. In order use it, you will need to download and install the VSIX file that contains the plugin.

Download and Install VSCode

If it isn't already installed on your computer, install Visual Studion Code (VS Code). You can download the latest version of VS Code from https://code.visualstudio.com/download.

Download and Install the .NET SDK

If it isn't already installed on your computer, install the .NET SDK version 8.0. You can download the SDK from https://dotnet.microsoft.com/en-us/download/dotnet.

Download the VSIX plugin

Download the latest VSIX release from the releases tab.

Install the plugin using "Install From VSIX" in the extensions menu.

Install From VSIX

Unzip the example

Download the example ZIP from the releases tab, and unzip this somewhere on your computer.

Do File->Open Folder and choose the folder where this was unzipped.

Open Example Folder

Start the example

Double click on the "dd4tmp.ampscript" file, then go to the "Run and Debug" section of the editor and click "Run and Debug".

Open Root File Open Root File

A browser window should appear with the example running. From here - you can make any changes to the example and reload your browser window.

Example Running

Subscriber Attributes

Subscriber attributes %%Foo%%/[Foo] are supported through a JSON file named subscriber.json in the working directory.

Supported within the JSON file is a key/value pair of the attribute name and value.

Example:

{
    "FirstName": "Logan"
}

The attribute values can be referenced via:

%%[
    SET @FIRSTNAME = [FirstName]
]%%

Hello %%=V(@FIRSTNAME)=%%
or
Hello %%FirstName%%

Referencing Content

Content functions can reference content local on disk. The files must exist in a Content subdirectory of the working directory.

Example, if you have a file at Content\EmbeddedContent.ampscript, then you can reference it via:

%%=CONTENTBLOCKBYNAME("EmbeddedContent")=%%

Data Extensions

Data Extension support is provided through CSV files on disk. The files must exist in a DataExtensions subdirectory of the working directory. The CSV file must contain headers which represent the columns.

Example, if you have a file at DataExtensions\Loyalty.csv, then it will use this CSV file as the data extension.

DataExtensions\Loyalty.csv

EmailAddress,SubscriberKey,FirstName,LastName,LoyaltyLevel
[email protected],1,Donnie,Stanton,Silver

Index.ampscript

Hello %%=LOOKUP("Loyalty", "FirstName", "emailAddress", "[email protected]")=%%

Outputs:

Hello Donnie

⚠️ AMPscript Support

Feature Summary
Ampscript Blocks %%[]%% ✔️
Variables ✔️
For for ✔️
If if ✔️
Logic Operators ==, !=, &&, etc ✔️
Inline Ampscript %%= =%% ✔️
Personalization Strings [Foo] or %%Foo%% ✔️
Tag Syntax <script language="ampscript"> ✔️
System Strings xtmonth, jobid, subscriberkey, etc ⛔ Not Yet Supported

Marketing Cloud Supported Languages

Language Summary
AMPscript ⚠️ Partial support
SSJS ⛔ Not supported
GTL ⛔ Not Supported

Supported Functions

If the function isn't listed here, then it's not supported.

Function Area Supported / Notes
Marketing Cloud API ⛔ Not Supported
Contact Model ⛔ Not Supported
Content ⚠️ Partial support
Data Extensions ⚠️ Partial Support
Date and Time ⚠️ Partial Support
Einstein ⛔ Not Supported
Encryption ⛔ Not Supported
HTTP ⛔ Not Supported
Math ✔️
Microsoft Dynamics ⛔ Not Supported
Sales and Service Cloud ⛔ Not Supported
Site ⛔ Not Supported
Social ⛔ Not Supported
String ⚠️ Partial Support
Utility ⚠️ Partial Support
Content Syndication ⛔ Not Supported

Roadmap

  • Increase supported feature
  • SSJS & GTL
  • Static code analysis tools to identify and remediate performance or security issues

Docs

About

AMPscript Core is an open source implementation of the Marketing Cloud AMPscript language.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 86.6%
  • HTML 8.7%
  • TypeScript 2.6%
  • ANTLR 2.1%