Overview
In this section, we will walk you through the programming concept of Stella, so that you can apply your code to the Actions and Advanced mode of any node.
Stella Runs on JavaScript
Stella is running on the latest JavaScript version. Specifically @babel/preset-env with @babel/plugin-proposal-async-generator-functions.
Chatbot Concept
Tree Diagram
Node to Match
Stella will save the node a member is last in. Then, the child nodes of the current node, the global nodes of the current tree or the global nodes of the channel can be the nodes to be matched when the member has another input.
For your quick reference, child nodes are the nodes directly connected to the current node. Global nodes are nodes in the upper section of the tree view. Channel global nodes are selected in channel view.
Priority
Every matched node will be sorted by their priority, with the lower value comes first. The first matched node will then be executed. If there are more than 1 nodes with the lowest value, a random one will be chosen and executed. The default priority of a node is 0
. The priority of a normal node doesn’t have an upper limit and can be set as low as -9
. Nodes with priority less than or equal to -10 is called a muted node and will be included in the documentation soon.
Channel Global
For a new user, the head node of all trees in channel, and the channel global nodes will be matched instead. Any global nodes which is selected in a channel can be triggered across a channel.
Processing of Tree Node & Global Node
When a node is matched, there is an order of execution from top-down as shown in the diagram below.
You may refer to the table below and find out how does a specific component (advanced) function in a node:
Reference | Description | Order of Execution |
---|---|---|
Trigger | A node is matched by computing its trigger. | 1 |
Pre-action/Action | An action is a Promise function that can be used for logics, internal database manipulation and external API calling. It runs before a response is sent. | 2 |
Response | A response object or an array of response objects can be resolved by the “resolve” callback of the promise function. It contains the chatbot message. | 3 |
Post-action/Action | An action is a Promise function that can be used for logics, internal database manipulation and external API calling. It runs after the response is sent. | 4 |
Member Tagging | Stella will add tags to a member when the member is passing through a node with member tag is toggled on. | 5 |
Analytics | When a node with analytics toggled on is executed for a member, either from trigger or redirect, an analytics event will be recorded. | 6 |
Redirect | When a node is successfully executed and if the redirect of the node is toggled on, the redirected node will be executed next. | 7 |
"this" Scope, Reference & Methods
During a chatbot session, i.e. from the point Stella receives a message event, to the point where all subsequent redirected nodes are executed, Stella will store temporary data and other related functions in the this
scope. All changes in this
will be passed through all parts of the nodes and redirections.
Stella has a list of Reference documentation for any advanced function or reference object.
Reference | Description |
---|---|
Message Event | Message event is an object provided by the platforms which contain the information about the message, which can be accessed by this.messageEvent . |
Node | Node is an object that exists in our database, which contains the information about the node, which can be accessed by this.node . |
Member | Member is an object that exists in our database, which contains the information about the chatbot member, which can be accessed by this.member . |
Channel | Channel is an object that exists in our database, which contains the information about the chatbot channel, which can be accessed by this.channel . |
Integrations | Integrations is an object that exists in our database and allows users to access related information regarding the integrations between Stella and available applications, which can be accessed by this.integrations. |
Agenda Meta | Agenda Meta allows users to pass different data to nodes for the use of agenda. Users can use this.newAgenda or redirectMemberToNode with meta object, the object can be later accessed by this.agendaMeta . |
Group | Available only on Teamwork and WhatsApp . Group is an object that contains all the information about the group. This is a property available only in live chat. Whenever there are some incoming or outgoing messages need to be processed by the bot or tree during live chat, this property will be added into the this object , which can be accessed by this.group . |
Methods | These are the methods that can be accessed by this . Most of the methods are crud operations on the database. You can make use of these method to perform different kinds of features like setting new agenda, sending emails, etc. |
Radiate.js | You can make use of Radiate.js to create different interactions between your web and the web chat. |
3rd Party Libraries | There are third-party libraries in the this scope. Node-fetch (this.fetch ) is a library for sending http(s) requests. Moment (this.moment ) is a library for time related logic. Lodash (this.lodash ) is a utility library that improves QoL. |
Applying Advanced Functions to Chatbot
You can try applying the above methods & objects to your chatbot flow. Follow the documentations below and test out some functions!