BookmarkSubscribeRSS Feed
SAS Employee

Santa needs a lot of helpers to bring presents to everyone around the world. The same way users of SAS Viya analytics platform can benefit from helper bots so that they can get data and analytical results faster to everyone in their organization. SAS Viya always includes the Conversational Designer functionality which allows you to build chatbots to interact with the platform and provide capabilities of Viya through a chat interface.


You can build many types of bots, but in this Juletip I want to focus on a simple helper bot that can perform data preparation tasks for anyone using Viya.


The first step is to create a new bot in Conversational Designer. In order to understand what a Viya user wants to do, we have to define an intent for the bot. Then we can give the bot few examples of different ways users can express their intent (uttrances) and finally we have to map that intent to a dialogue flow.


1. Create a new intent of "Join tables". Add some example utterances and save the most important words as entities.

Defining intentsDefining intents


2. Start building your dialogue flow. The first node should map to the user intent that triggers the dialogue flow (=the "Join tables" -intent).

Creating dialoguesCreating dialogues


3. After the dialogue has been triggered by the intent, the bot should answer something back to the user. In this case, we ask the user to provide the name of the first data table they would like to include in the join.

Defining responsesDefining responses


4. We record the user input to parameter variables (in this case named "firsttable" that we later use to execute the join code. In similar way, we can ask the user for the name of the second table they want to include to the join and also the key variable that should be used. Depending on the data preparation step you want the bot to execute, the variables you need to ask from a user can change.

Setting input parametersSetting input parameters


5. When all the required parameters have been given by the user, the join can be executed using the SAS Code Data Provider step. I have included the join table example code below that uses 3 parameters that are required from the user. The code assumes that the source tables are found in CASUSER library and the bot puts the resulting joined table into the CASUSER library as well. Of course if you want to make your bot more versatile, these could be filled by parameters as well so that the user has more control over the join.

SAS Code ProviderSAS Code Provider



caslib _all_ assign;

%global tableone;
%let tableone=&firsttable;
%global tabletwo;
%let tabletwo=&secondtable;
%global jkey;
%let jkey=&joinkey;

proc sql;
    create table final_table as
    select * from casuser.&tableone as x left join casuser.&tabletwo as y
    on x.&jkey = y.&jkey;

data casuser.joinedtable (promote=yes);
    set work.final_table;



6. After everything has been configured, it is possible to test the bot using the "Try It Now" button.

Test your botTest your bot


7. The resulting table can now be found in your CASUSER library. Congrats, you have now developed your first dialogue for your helper bot!

7 Bot has created a new table as a result of the join7 Bot has created a new table as a result of the join

8. Typically after the bot has been tested, it will be deployed on a web server and integrated on a website, a Visual Analytics report or MS Teams.


Thanks for checking out this SAS Viya Conversational Designer Juletip! Merry Christmas and happy New Year!


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


Register now!

Discussion stats
  • 0 replies
  • 1 in conversation