Skip to content


Function resources allow you to write custom Javascript code that you can call from any chatbot to apply special processing on your variables.

These special functions can return either directly executable workflows or raw data that would be displayed / processed later on.

1. Creation

When editing your function from your dashboard, a wide code area will let you save your custom function.
The only parameter you receive is the following request object :

interface request {
  timestamp: string; // DateTime of the call
  sessionId: string; // Session identifier
  bot: {
    id: string; // Wizard identifier
  user: { // Current user
    id: string; // User ID
    location: string; // Location of the user if authorized by the user
    platform: string; // User agent platform
    conversationSize: number; // Number of messages in the conversation
    conversationId: string; // ConversationId: string; // ConversationId identifier
  userMessage: { // User message
    event: string; // If the user's message is an event, its name
    text: string; // If it's text, its content
    payload: {}; // If the message contains an arbitrary object, this one
  originalRequest: {}; // Object of arbitrary parameters passed to the injection script
  lang: string; // User's browser language
  query: string; // Request sent by the user
  event: string; // Event sent by the user
  fulfillment: { // Responses generated by the workflow before arriving at the function
    stream: {
      type: string;
      resourceId: string;
  intent: { // Intent corresponding to the user's request
    name: string;
    confidence: number; // Match index
    inputs: {}; // Value of intent parameters
  contexts: { // Contexts
    lifespan: string; // Lifetime
    required: boolean; // If required
    name: string; // Name
    parameters: {}; // Associated parameters
    scope: string; // Perimeter
  endConversation: boolean; // If the convesation is over

So, if the content of my function is :


The function will return the id of the bot running the function.

It is possible to execute asynchronous code using the keywords async/await :

const res = await fetch("");
const data = await res.json();
return data.value;

Some javascript libraries are available among which :

  • fetch : allows to make http requests
  • DOM: allows you to parse the DOM. Used with the DOM(document: string) function which returns a DOMElement.

To access other libraries, please contact us.

Function return

The function can either return raw data, simple text to display or a workflow :

// Displays "Hello world"
return "Hello World";

// Returns raw data to display / process later on  
return [{"title": "Hello World"}];
// Return 1 text response followed by one button
return [
   {"text" : "Of course"},
   {"type": "richText", "text": "<b>Rich text</b>"},
   {"type" : "panel", "value": "Thats side panel content, which can be <b>enriched</b> as well"},
   {"type" : "button","text":"click me","value":"text message sent by this button"},
   {"type" : "event","text":"click me","value":"EVENT_NAME"},
   {"type" : "link","text":"im a link","value":""},
     "type" : "card",
     "title":"I am a card",
     "text":"some text..",
        {"type":"button","text":"Texte du bouton","value":"text message sent by this button"}

More information on workflows here.

2. Calling your function

Either from DSUL or from the graph editor, you can call your recently created function with its only available action : function

If your function returns raw data instead of a standard workflow, you first need to save it in a variable using output option, before reading it from next responses.