like-gold
like-goldβ€’16mo ago

How do I create a javascript function?

How do I create a javascript function in Voiceflow?
6 Replies
Tico | Voiceflow Assistant
Creating a JavaScript function in Voiceflow involves a few steps. 1. Access the Functions Page: This is the central hub for managing custom functions and capabilities of your AI agent. Here, you can create, edit, and organize functions that execute logic calculations based on user inputs and data. 2. Create a New Function: On the Functions page, click on the 'New function' button in the upper right area of the screen. A modal will appear for you to enter details for the new function. 3. Enter Function Details: Enter a name for the function in the 'Name' field. Choose a name that represents the function's purpose, such as 'Create Ticket'. Provide a description in the 'Description' text box that explains the function's purpose. This description will be displayed on the function step editor on the canvas for designer visibility. 4. Save the Function: Once all information is entered, click 'Create function' to save the new function. Now, you have created a new function. The next step is to define the function's code. Every function is contained within the main function which is the default export and the entry point for Voiceflow to execute the code when the function step is triggered. Here's a basic example of a JavaScript function in Voiceflow:
export default async function main(args) {
// Your function logic goes here
}
export default async function main(args) {
// Your function logic goes here
}
Remember, the function code is only covering the function logic. The function interface, which outlines inputs, outputs, paths, and dictates behavior, is a separate aspect. Lastly, it's important to note that certain JavaScript methods, like setTimeout(), are not supported due to dependence on browser or Node.js runtime APIs that are not part of the ECMAScript (JavaScript) language specification. You can refer to the JavaScript reference document for a list of built-in objects supported by functions code in Voiceflow.
Conner
Connerβ€’16mo ago
"Hi my name is @Daniel and I like to play with Tico during my downtime."
like-gold
like-goldOPβ€’16mo ago
HAHAHAHAHAHA @Conner we're filming a video πŸ˜‚ Gotta spot check Tico every know and then to make sure its not getting too sentient πŸ”
Conner
Connerβ€’16mo ago
If Tico goes off the rails, we're all doomed! Feature request: Tico start building assistants on his own
like-gold
like-goldOPβ€’16mo ago
Im scared This may or may not be on the Tico roadmap πŸ‘€
Conner
Connerβ€’16mo ago
No description

Did you find this page helpful?