What follows is a video describing how to use snippets to share steps among robots.
Creating complex robots can quickly become a messy affair which hogs precious screen real-estate. Putting steps into groups is an easy way to clean up such a robot and simplify the steps it takes to reach the end result.
To group steps you simply select the steps you want to group then press the group button in the tool bar above the robot editor.
Furthermore you can give each group a name when you create it. This makes it easier to keep track of the specific function of the group.
Collecting independent parts of a complex robot into simple groups makes the robot much easier to understand for yourself and others.
Naming groups to remember their insides is essential. We could for example have a group that logs into a site, performs a complex conversion, stores values in a database, or looks something up online.
Thinking about it, I actually have a login group in one of my robots which I would also like to use in some of my other robots. Now I could of course start copying and pasting this group into some of my other robots. That would solve the problem for now but if I needed to change the login procedure in the future then I would have to copy the modified group step into all my robots again.
Let me introduce the snippet concept. A snippet is created and edited as a group step but is stored in a separate file and can be used as a custom step in as many robots as you want.
Having the step information stored in a separate file from the robots, means that changing the snippet in one robot will change it in all of the other robots as well. This can save a lot of time and greatly simplify your robots.
…In addition to containing steps, snippets can also include a list of variables used by the snippet.
It could for example be a login variable containing username and password. This variable is then automatically available in every robot using this snippet.
CREATING A SNIPPET
Let me show you how this all works in Design Studio.
Here is a robot which logs into Zoho CRM, looks up some contact information, extracts it and returns it. The login procedure of this robot has been grouped and would be perfect to have handy for other robots which are also to perform tasks on Zoho.
Creating a snippet from the steps that perform the login sequence couldn't be easier. I simply select the group I already made. Then I select Convert Group to Snippet from the tool bar above the robot editor.
Design Studio now prompts for a name and I choose the name LoginZoho which was already the name of the group.
The snippet is then created which is visualized by the small snippet icon in the lower left corner of the box.
Furthermore the newly created snippet file has been selected in the projects view and the snippet has also been opened in the snippet editor in a new tab. The snippet editor will open every time we modify our snippet in a robot.
I switch to the LoginZoho snippet editor. The snippet editor looks very much like the robot editor. It has a snippet view showing the steps of the snippet, a step view showing the action performed by the active step in the snippet view and a variables view as we know it from the robot editor. Instead of the browser view, the snippet editor has a configuration view where we can write a description of the snippet.
Note that in the snippet editor we can only make modifications to the configuration view and the variables view. If we want to make modifications to the steps in the snippet we will need to do that in the context of a robot editor.
As you may have noticed when looking at the snippet view, the two steps which use the Login variable have been marked with error indicators, pointing out that the variable is not yet present in the snippet.
Accordingly, the last thing we have to do to complete our snippet is to add the Login variable to the snippet. This will ensure that the login credentials will be available to any robot which uses this snippet.
I add it by simply right clicking the variables view and choosing the appropriate type, exactly as I would have done in a robot. In the variable configuration window that now appears I have to ensure that I configure the variable to match the one in the robot precisely. The variable name is correct so I just need to check Use as Input and add default values to the attributes… then I click OK.
Now we have a fully functional LoginZoho snippet.
USING THE SNIPPET
Let me show you how to add the snippet to another robot. Here's a new robot which I also want to perform some task on Zoho. A snippet step is inserted by choosing Insert Snippet Step Before from the tool bar.
An undefined snippet step now appears in the robot. I then choose the LoginZoho snippet from the dropdown in the step view of the snippet step.
The snippet has now been inserted into the robot and can be executed by clicking the end step…
As seen in the variables view, the login variable from the snippet is now available for the robot to use. The small snippet icon to the left of the variable indicates that this variable belongs to the snippet. That means that we cannot edit the variable directly in the robot, but only in the snippet editor. It also means that removing the Login snippet from the robot will remove the variable as well.
If we want the variable to be in the robot permanently then we have to add it manually to the robot, giving it the same name, type and configuration as the login variable from the snippet. This new variable will then take the place of the snippet variable.
Now, if I make a change to the snippet in any of its instances, all the other instances will also be changed. If I for example switch the places of the Enter Username and Enter Password steps and then go back to the first robot, we see that the order of the two steps has been changed here as well.
To round off this video let me give you some tips when working with snippets.
Often you can end up with robots having huge variables containing everything needed for that robot. When creating snippets you should ultimately split these variables such that only the attributes needed in the snippet will be included in the snippet variable.
In general you should try to create your types based on function rather than making them robot specific.
To make the snippet as independent from the rest of the robot as possible, make sure to put any non-default robot configuration directly into the steps in the snippet where necessary.
In other words if you have clicked here, then here and made any changes that are important to the steps in the snippet, then make sure to click here in step view for the steps of the snippet and make the same changes.
Always document the context of the snippet by writing a description in the snippet configuration view.
That is all for this video. If you want to learn even more about snippets you can consult the documentation at help.kapowsoftware.com.