Managing executable scripts (code snippets)
Executable scripts are an advanced AIsuru feature that lets you integrate and run code directly within conversations with your Agent. This powerful capability lets you:
Display correctly formatted code examples;
Execute scripts and modify the user interface in real time;
Create interactive and dynamic experiences;
Provide immediate technical demonstrations.
How to add executable scripts
Go to your Agent's Contents and create or edit a content;
Go to the "Advanced: executable scripts" section and click "+ New snippet";
In the panel that opens:
Add a title for the code snippet;
Enter the code;
Decide whether to run the code on the page by enabling the "Insert in page and execute this snippet" checkbox (available only for certain languages). This checkbox lets you:
Always run the snippet when the user asks exactly the same question as your content (or something close enough);
Have the generative AI run the snippet (at the model's discretion).
The generative AI uses the snippet title to decide if and when to run it. If you want the generative AI to execute your snippet, make sure to choose descriptive names and explain when to use the snippet in your prompt.
Supported languages
You can choose from the following languages for your snippet:
text
✅
❌
javascript/jsx
✅
✅
typescript/tsx
✅
✅
json
✅
✅
css
✅
✅
html/xml
✅
❌
bash
✅
❌
python
✅
❌
cpp/csharp
✅
❌
php
✅
❌
ruby
✅
❌
Practical examples
Goal: highlight a section of the web page;
Title: "Highlight product description";
Language: JavaScript;
Insert in page and run this snippet: checkbox enabled.
Code:
Conversation flow:
User: "Where can I find the product description?";
Agent:
"The product description is below the title, in the upper right. To help you out, I've highlighted it for a few seconds."
[Inserts and runs the 'Highlight product section' snippet]
Benefits of using executable scripts
Creates more dynamic and context-aware interactions;
Improves the user experience with visual, interactive examples;
Provides immediate and practical technical support;
Lets you customize the user interface in real time;
Makes it easier to demonstrate site or application features.
Advanced snippet combinations
Snippets can be combined strategically to create more complex interactions:
Example: dynamic section highlighting
Imagine creating a guided experience where the Agent highlights different parts of the page during a conversation. You could set up:
A CSS snippet (via opening question)
A JavaScript snippet (in the same opening question)
A JavaScript snippet linked to the content with question "Where is the products section?"
This way, when the user opens the chat:
The CSS style is immediately injected;
The JavaScript function for highlighting the section is defined.
When the user asks "Where is the products section?", the Agent will trigger the third snippet — and therefore the function that highlights the section.
This approach is particularly useful for:
Interactive guided tutorials;
Onboarding new users;
Navigation assistance on complex pages;
Product or service presentations.
Important considerations
Security: when using the snippet execution option, make sure the code is safe and can't be manipulated to perform harmful actions;
Transparency: always provide a clear explanation of what the snippet does or shows;
Accessibility: not all users may see the visual effects of snippets, so always provide text-based alternatives;
Performance: avoid loading the page with too many executable snippets, which could slow down the user experience.
Smart use of executable scripts can turn your Agent into a powerful interactive support tool. Experiment with different types of snippets to create an engaging, informative, and personalized user experience — significantly improving the interaction between users and your website or application.
Last updated