Only without hands! Robots that do not repeat user actions

    This review article is about how to use RPA for business processes, which include tasks that ordinary people are not able to perform, do not want to, or it takes them a lot of time and requires special knowledge, such as working with FTP, databases or API.

    The inclusion of such actions in the process brings its creation closer to traditional programming and "scripts", with all the pros and cons of this approach.

    Using the API even in tasks traditional for robotics can significantly increase the speed of their execution, increase reliability and stability, but at the same time it removes us from realizing the dream of business users creating and supporting their processes themselves, and definitely returns their development and support to their hands development teams.

    When it is possible, and when it is necessary to add actions to a lower level in the process, I will try to tell in this article. The first, introductory part, contains general considerations, and the second contains specific examples. Examples are given for a platform with which I am well acquainted (UiPath), so for those who prefer other tastes and colors of robots, please do not be offended in advance.



    Pro and Contra Robotics Low


    Why are such robots useful?


    • Significantly accelerated work. Often this is the main reason why we think about low-level interaction with external systems. If we can make the process 10 times faster, we can save on the use of additional robots, with their virtual machines and licenses.
    • Reliability is increased, you no longer need to work with fancifully dynamic selectors in the UI, think about how to bypass the captcha, fight for the accuracy of recognizing a picture in Citrix that you can’t put a plugin on, or fight endless scrolling on the news page.
    • Work with systems that do not have a full UI or do not allow you to get all the necessary information through the UI. For example, in my practice there was a case when we took data on the API from Shopify , transferred it to ShipHero and sent it to the internal accounting system. Only the last step used the user interface.

    Why are such robots harmful?


    • Business users no longer understand what our robotic process does and cannot change and maintain it themselves. This is not so true for Unattended robots, but for Attended (digital assistants) this is a significant minus, because we want users to be the authors of their processes themselves.
    • The visibility and understandability of the process for the security service is lost. If with an ordinary robot we can clearly demonstrate that he is doing the same actions as the “organic” user, it is even possible to use job descriptions as documentation, then using low-level integration we are forced to agree that our process must go through the same lengthy verification and control procedures as the “big” automation.
    • Dito, regarding integration teams. As soon as we start using the API, we fall into their estate and must play by their rules.
    • The cost and risks of “real” programming are greater than robots. If a person can press a button, a robot can also press it. But can the API of an ancient undocumented system provide us with the necessary data? Is it possible to write information directly to the database, or will we destroy its integrity? Is an experienced specialist necessary for this task or is it enough for a novice student? Why does Slides.Duplicate in PowerPoint.Interop return an array? The answer to all these intriguing questions can be obtained, but it will take time.

    When you need and when you should not use programming in robots


    The above can be summarized as follows:

    Programming is worth using if


    • Your process lacks productivity
    • UI systems are not convenient for automation, but there is a convenient API

    Programming should not be used if


    • Processes will be developed or supported by business users.
    • Using the API makes it difficult for the robot to go through negotiation processes.



    With what and how does it make sense to work through code?


    Then I tried to give some examples of working with code, which, one way or another, I had to really use when creating robots, which means that they take place in life. Naturally, the list is not exhaustive, but I hope it is illustrative.
    Examples are all tested on the latest release versions of the actions at the time of writing.

    Microsoft Office


    Oddly enough, one of the first candidates to work through the API is Microsoft Office. Yes, UiPath has excellent built-in functionality for working with Excel (even two types, one with files directly, the second through the application). There are also opportunities to work with Word (a package UiPath.Word.Activitiesis installed through the package manager). But, for example, there are no standard actions for working with PowerPoint, and there is also Outlook or even Visio with Project, which are still quite actively used in large companies. With Office it is quite possible to make friends with a robot through the user interface, but in some cases it is not very convenient, since not all UI elements can be accessed directly and you have to play scales on the keyboard. For example, an action Type Intowith the text k [tab] k [f10] JCDD(for the English version of Office) will open the chart data from a PowerPoint slide for editing in Excel. Such combinations work well, but look like magic cleaner than IDDKQD.
    ProTip: The list of available selectors can be expanded using a framework in place Microsoft Active Accessibility (MSAA), which is selected by default Microsoft UI Automation (UIA). Switch to it with the F4 button in UI Explorer and see if there is a difference
    To work with office files, you can use third-party libraries, for example Xceed DocX or Spire libraries, such as Spire.Presentation . When working with third-party libraries, pay attention to the license, it may not always be suitable for your company (for example, iTextSharp for PDF is distributed free of charge via AGPL , and PDFSharp - via MIT ). This method is very convenient, since it can be used even if Microsoft Office is not installed on the machine, which means that it is great for Unattended robots running on virtual machines.

    For complex work with office programs comes to the rescueMicrosoft.Office.Interop. It allows us to perform actions inside applications, manipulate data, etc. You can devote more than one article to the features of working with Office.Interop, an ancient and fragile thing, but it will be suitable for our purposes. In order for Interop to work, you need to add the appropriate assemblies to Imports.

    Here are a couple of examples of what you can do with Office Interop:

    Outlook


    The functionality of Outlook is much wider than just working with mail, it is a personal information manager, and there is a calendar, and a notebook, and an address book, in general, a complete set. If everything with email can usually be solved by direct access to the server, if it represents IMAP / POP3 interfaces, then the rest of the information is much easier to get from Outlook itself. For this Interop fits perfectly.

    Getting a list of calendar events
    Dim oApp As New Microsoft.Office.Interop.Outlook.Application
    Dim mapiNamespace As Microsoft.Office.Interop.Outlook.NameSpace
    Dim calendarFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
    Dim calendarItems As Microsoft.Office.Interop.Outlook.Items
    mapiNamespace = oApp.GetNamespace("MAPI")
    calendarFolder = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar)
    calendarItems = calendarFolder.Items
    calendarItems.IncludeRecurrences = True


    Powerpoint


    Using PowerPoint, you can not only create beautiful presentations, but also use it for paperwork, such as commercial offers or regular project reports. To do this, you need to show data from other sources in PowerPoint, and, of course, the robot does an excellent job of this. Most of the time when creating PowerPoint slides takes to beautifully design them, so you can do this in advance, and substitute real data by copying template slides and replacing texts with them.
    Microsoft.Office.Interop.Powerpoint and all other Interop builds can be found in the nuget.org repository.
    Duplicate slide
    Due to the fact that Presentation is in System.Activities, and Application - in other Interop, you have to write class names completely. fileName and slideToCopy - arguments, string and number, respectively.

    Dim app As New Microsoft.Office.Interop.PowerPoint.Application
    Dim pres As Microsoft.Office.Interop.PowerPoint.Presentation
    Dim newSlide As Microsoft.Office.Interop.PowerPoint.Slide
    pres = app.Presentations.Open(fileName)
    newSlide = pres.Slides(slideToCopy).Duplicate()(1)
    


    Further through the Shapes collection containing all the elements of the slide, you can quickly update the necessary information on a new page

    Work in Word


    Although the activities in the Word Activities Pack provide basic Word features, they do not cover the full functionality of the Xceed DocX library on which they are built. The most common case is working with tables, but there are many other cases.

    There are enough different examples in the project repository to understand where this or a similar library will be useful.

    Web API (REST, SOAP)


    REST / JSON is now probably the key link in order to provide integration with systems representing the API.

    Support for REST, SOAP, and JSON is provided through the Web Activities Pack .
    With REST, everything is quite simple, as it should be: HTTP Request-> Deserialize JSONand now we already have a JObject with which we can do whatever we want. In order to transfer data to the web service there is a convenient parameter editor.

    But for SOAP, the built-in functionality, unfortunately, is limited, not all types of web services are supported, not all requests are processed correctly. If the service does not work for you, you have to use one of the many wrappers for HttpClient, for example, SimpleSOAPClient or write your own (option to work with SOAP from C # ).

    UPDATE 04/03/19: In version 2019.4, the beta of which is already available for download, the component is updated, improved and redone. So you can expect the appearance of normal SOAP support very soon

    Work with FTP


    Here in UiPath, everything is simple, there is a ready-made set of actions for FTP included in Community Activities , although it should be noted that, starting with version 18.2 of the FTP Activities Pack in the deprecated status . But all the functionality is there, even SFTP is supported (the set is based on SSH.NET ), although, unfortunately, work with the client key has not been completed.

    .

    Database


    UiPath works with databases through the .NET Data Provider. For MS SQL and MS Access, everything is simple, for the rest you need to configure ODBC, and if it is not there, install the driver. Keep in mind that since, at the moment, the platform is 32-bit, then we need to download the appropriate driver and the ODBC data source must be the same.

    Below is an example for working with MySQL.

    Configure MySQL connection
    Настройки тестовой удаленной базы MySQL (драйвер отсюда):

    и подключаемся к ней из действия


    Further work with an SQL-compatible database is fairly standard - we make queries, we get a DataTable.

    SAP through BAPI


    If your SAP gives you this opportunity, you can try instead of working through the UI to automate integration with SAP through the BAPI. As usual, UiPath has a ready-made
    set of actions for this , including a wizard for configuring connections to SAP. There is almost no programming here, but this is an example of the fact that the standard integration path is not the only one possible.

    Finally


    I hope that with the help of this article I was able to talk about those aspects of using robots that are not so easy to learn about at the Academy or at the Forum . I would be glad if someone becomes interested in or helps to answer questions related to the development of robots.

    Also popular now: