Drag and drop the block and connect it to the state where you want to see executed.
You can then add your own code, it will be hosted and executed in the secure and scalable servers of the bot platform.
Warning : If you use a "bot does" after a "bot shows", the bot does will be prioritarty
You can then double click on the block to open the integrated code editor.
You can see some commented code snippets that may be helpful.
We currently offer support for Node.js, additional languages may be available in the future.
The code editor comes with a dark mode.
- Create a dynamic answer
- Access entities and contextual values
- Send requests to your preferred APIs and databases
- Control connected devices
- Implement business logic or complex algorithms
- ...and much much more!
While coding your business logic, please keep two things in mind:
- In the case your code takes time to be fully executed, please keep in mind that you have a 90 seconds limit, after that, beyond that limit, the code execution will be stopped and your bot will return a timeout.
- Always have the `callback(output)``in your code, wich indicates to the platform that your custom code has been fully executed.
callback(output); // 👈 Never Forget this callback
Yes you can.
Here is how you can store data as conversation context
conversation.shared_memory.my_new_field = 'my_value';
If you are using the main bots / micro bots architecture, the data stored in the
conversation.shared_memorywill be available across all the microbots.
If some user data has been sent to the bot platform, you may access it by code using the following syntax:
var first_name = user_data.first_name;
Sure! Here is the code to so:
var user_message = input.text;
Sure, that's the purpose of custom and system entities.
Let's see how you can do that.
- Custom entities
Assuming, you have created an entity called
colors, and added it to an intent that has been detected,. You can get your custom entity using the following syntax:
var color = input.custom_entities.colors.value;
- System entities
The platform offers pre-trained entities that you can capture anytime using the appropriate syntax.
Also, please check the system entity availability in the Language Support page.
// time: today, Monday, Feb 18, the 1st of march var time = input.system_entities.time.value; // temperature: 70°, 72° Fahrenheit, thirty two celsius var duration = input.system_entities.duration.value; // number: eighteen, 0.77, 100K var number = input.system_entities.number.value; // amount of money: ten dollars, 4 bucks, $20 var amount_of_money = input.system_entities.amount_of_money.value; // duration: 2 hours, 4 days, 3 minutes var duration = input.system_entities.duration.value; // email: [email protected] var email = input.system_entities.number.value; // url: https://smartly.ai, www.google.com var url = input.system_entities.url.value; // phone number: 012345678 var phone_number = input.system_entities.phone_number.value;
You can change the editor’s theme to dark and also make the editor full screen.
Leveraging your webservices can unleash valuable use cases to your users.
Here is a list of things you can do to keep a good level of security while connecting your bot to your IS via public APIs:
- Use a public key in your API calls
- Use a private key for the bot and change it at least once a month
- Use a dedicated and expirable access token for each user
- Use IP filtering to restrict the access to your API to the following adresses: Bot Platform IP adresses
Current version of Node.js you can use in your bots is 10.1.0 Dubnium.
The following packages have been pre-installed.
You can use them directly in your bot projects.
As usual in Node, simply add a
require('package name') at the beginning of your code before using the package.
//if you want to use the mysql package var mysql = require ('mysql');
Need a specific package?
If you need a specific package for your app, send us a request at [email protected] and our team will review it.
Updated 14 days ago