Introduction
This document provides guidance on using JavaScript (NodeJS) snippets within the Floatbot platform. These snippets are versatile and can be utilized in different parts of the platform including Prompts, Workflows, and AgentM
Snippet lets you create JavaScript (NodeJS) APIs that you can use to push/pull data from backend, call third party APIs and more.
Goto variables >> snippet
Snippet Locations
You can select the desired location for your snippet usage via a dropdown menu located at the top right of the interface.
Accessing Attributes with `params`
Output of the Snippet
Use Cases
Schema of the `item` Object
The schema for the `item` object is detailed in the following TypeScript interfaces:
interface Item {
set_attributes?: { [key: string]: string };
data: DataItem[];
}
interface DataItem {
code: string;
text: string;
nextAgentM?: boolean;
attribute: string;
as_dropdown: boolean | 0 | 1;
quick_reply?: QuickReply[];
cards?: Card[];
buttons?: Button[];
image?: Image;
}
interface QuickReply {
title: string;
key: string | number;
icon_url?: string;
redirect?: string;
}
interface Card {
image_url?: string;
title?: string;
subtitle?: string;
item_url?: string;
buttons?: Button[];
}
interface Button {
title: string;
target?: boolean;
type?: string;
visitor_counter?: number;
redirect?: string;
link?: string;
attributes?: string;
success_attributes?: string[];
currency?: string;
price?: number;
invoiceTable?: InvoiceTableItem[];
}
interface InvoiceTableItem {
name?: string;
price?: number;
}
Below is a snapshot showing how to return quick replies from snippet
Below is a snapshot showing how to return text item from snippet
Once you have created your snippet, you need to select it from workflow/ prompt or agent M