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
Add snippet by giving name to your snippet
You can run, save or download your snippet.
Snippets can be used within workflows, prompt or agent, select from the dropdown as per your requirements.
You can run and test your snippets by mentioning test cases.
Snippet Locations
LLM Prompts
Workflow
AgentM
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`
The `params` object is available for accessing passed attributes.
For example, `params.first_name` can be used to access the `first_name` variable.
Output of the Snippet
The output is determined by the value assigned to the `item` object within your snippet.
In AgentM: The `item` variable should be a string.
In Prompts and Workflow: The `item` variable should adhere to a specific schema.
Use Cases
The snippet can be used to display text, buttons, cards, and quick replies.
It can also return `null` for an empty response.
The `set_attributes` object within the snippet can be used to set user specific variables.
Schema of the `item` Object
The schema for the `item` object is detailed in the following TypeScript interfaces: