Python API


class RPA.Dialogs.Dialogs(server_port: int = 8105, stylesheet: str = None)

Bases: object

The Dialogs library provides a way to ask for user input during executions through HTML forms. Form elements can be built with library keywords or they can be defined in a static JSON file.

How the library works

The main keyword of the library is Request Response which works as follows:

  1. It starts an HTTP server in the background

  2. The HTML form is generated either according to a JSON file or the keywords called during the task

  3. It opens a browser and shows the created form (The browser is opened with the Open Available Browser keyword from the RPA.Browser.Selenium library)

  4. Once the form is filled and submitted by the user, the server will process the response and extract the field values, which in turn are returned by the keyword

  5. In the end, the browser is closed and the HTTP server is stopped

Request Response can be invoked in two ways:

  1. Without any parameters. This means that form shown is the one created by other library keywords. If no form elements have been added with keywords then the form will contain just one submit button. Form building must be started with the keyword Create Form.

  2. Giving a path to a JSON file (using the parameter formspec) which specifies the elements that form should include.

The keyword has optional parameters to specify form window width and height. The default size is 600px wide and 1000px high.

Setting library arguments

Library has arguments server_port and stylesheet. The server_port argument takes integer value, which defines port where HTTP server will be run. By default port is 8105. The stylesheet can be used to point CSS file, which will be used to modify style of form, which is shown to the user. Defaults to built-in Robocorp stylesheet.

Supported element types

As a bare minimum, the form is displayed with a submit button when the Request Response keyword is called.

The supported input elements and their corresponding HTML tags are:

  • form (<form>)

  • title (<h3>)

  • text (<p>)

  • radiobutton (<input type='radio'>)

  • checkbox (<input type='checkbox'>)

  • dropdown (<select>)

  • textarea (<textarea>)

  • textinput (<input type='text'>)

  • fileinput (<input type='file'>)

  • hiddeninput (<input type='hidden'>)

  • submit (<input type='submit'>)

About file types

The Add File Input keyword has parameter filetypes. Parameter sets filter for file types that can be uploaded via element. Parameter can be set to filetypes=${EMPTY} to accept all files. Multiple types are separated with comma filetypes=image/jpeg,image/png.

Some common filetypes:

  • image/* (all image types)

  • audio/* (all audio types)

  • video/* (all video types)

  • application/pdf (PDFs)

  • application/ (.xls, .xlsx)

The list of all possible MIME-types.


Robot Framework

Examples of creating forms through keywords and a JSON file:

*** Settings ***
Library    RPA.Dialogs

*** Keywords ***
Ask Question From User By Form Built With Keywords
    Create Form     questions
    Add Text Input  label=What is your name?  name=username
    &{response}=    Request Response
    Log             Username is "${response}[username]"

Ask Question From User By Form Specified With JSON
    &{response}=    Request Response  /path/to/myform.json
    Log             Username is "${response}[username]"


The library can also be used inside Python:

from RPA.Dialogs import Dialogs

def ask_question_from_user(question, attribute):
    d = Dialogs()
    d.add_text_input(label=question, name=attribute)
    response = request_response()
    return response

response = ask_question_from_user('What is your name ?', 'username')
print(f"Username is '{response['username']}'")
add_checkbox(label: str, element_id: str, options: str, default: str = None) → None

Add checkbox element

  • label – check box element label

  • element_id – check box element identifier

  • options – values for the check box

  • default – check box selected value, defaults to None


Create Form
Add Checkbox    label=Select your colors
...             element_id=colors
...             options=green,red,blue,yellow
...             default=blue
add_dropdown(label: str, element_id: str, options: Any, default: str = None) → None

Add dropdown element

  • label – dropdown element label

  • element_id – dropdown element id attribute

  • options – values for the dropdown

  • default – dropdown selected value, defaults to None


Create Form
Add Dropdown  label=Select task type
...           element_id=tasktype
...           options=buy,sell,rent
...           default=buy
add_file_input(label: str, element_id: str, name: str, filetypes: str, target_directory: str = None) → None

Add text input element

  • label – input element label

  • element_id – hidden element id attribute

  • name – input element name attribute

  • filetypes – accepted filetypes for the file upload

  • target_directory – where to save uploaded files to

Read more of the filetypes in the library documentation.


Create Form
Add File Input  label=Attachment
...             element_id=attachment
...             name=attachment
...             filetypes=${EMPTY}         # Accept all files
...             target_directory=${CURDIR}${/}output

Add File Input  label=Contract
...             element_id=contract
...             name=contract
...             filetypes=application/pdf  # Accept only PDFs
...             target_directory=${CURDIR}${/}output
add_hidden_input(name: str, value: str) → None

Add hidden input element

  • name – input element name attribute

  • value – input element value attribute


Create Form
${uuid}   Evaluate  str(uuid.uuid4())
Add Hidden Input    form-id   ${uuid}
add_radio_buttons(element_id: str, options: str, default: str = None) → None

Add radio button element

  • element_id – radio button element identifier

  • options – values for the radio button

  • default – radio button selected value, defaults to None


Create Form
Add Radio Button   element_id=drone  buttons=Jim,Robert  default=Robert
add_submit(name: str, buttons: str) → None

Add submit element

  • name – element name attribute

  • buttons – list of buttons


Create Form
Add Submit    name=direction-to-go  buttons=left,right
add_text(value: str) → None

Add text paragraph element


value – text for the element


Create Form
Add Text       ${form_guidance_text}
add_text_input(label: str, name: str, value: str = None) → None

Add text input element

  • label – input element label

  • name – input element name attribute

  • value – input element value attribute


Create Form
Add Text Input   what is your firstname ?  fname   value=Mika
add_textarea(name: str, rows: int = 5, cols: int = 40, default: str = None) → None

Add textarea element

  • name – textarea element name

  • rows – number of rows for the area, defaults to 5

  • cols – numnber of columns for the area, defaults to 40

  • default – prefilled text for the area, defaults to None


Create Form
Add Textarea       name=feedback  default=enter feedback here
Add Textarea       name=texts  rows=40   cols=80
add_title(title: str) → None

Add h3 element into form


title – text for the element


Create Form     # default form title will be "Requesting response"
Add Title       User Confirmation Form
create_form(title: str = None) → None

Create new form


title – form title, defaults to None


Create Form     # form title will be "Requesting response"
Create Form     title=User Confirmation Form
request_response(formspec: str = None, window_width: int = 600, window_height: int = 1000, timeout: Optional[int] = None) → Dict

Start server and show form. Waits for user response.

  • formspec – form json specification file, defaults to None

  • window_width – window width in pixels, defaults to 600

  • window_height – window height in pixels, defaults to 1000

  • timeout – optional time to wait for response, in seconds


form response


Create Form    ${CURDIR}/${/}myform.json
&{response}    Request Response
class RPA.Dialogs.Handler(request, client_address, server)

Bases: http.server.BaseHTTPRequestHandler

Server request handler class


alias of http.client.HTTPMessage


Return the client address.


Return the current date and time formatted for a message header.

default_request_version = 'HTTP/0.9'
disable_nagle_algorithm = False

Send the blank line ending the MIME headers.

error_content_type = 'text/html;charset=utf-8'
error_message_format = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"\n "">\n<html>\n <head>\n <meta http-equiv="Content-Type" content="text/html;charset=utf-8">\n <title>Error response</title>\n </head>\n <body>\n <h1>Error response</h1>\n <p>Error code: %(code)d</p>\n <p>Message: %(message)s.</p>\n <p>Error code explanation: %(code)s - %(explain)s.</p>\n </body>\n</html>\n'

Handle multiple requests if necessary.


Decide what to do with an “Expect: 100-continue” header.

If the client is expecting a 100 Continue response, we must respond with either a 100 Continue or a final response before waiting for the request body. The default is to always respond with a 100 Continue. You can behave differently (for example, reject unauthorized requests) by overriding this method.

This method should either return True (possibly after sending a 100 Continue response) or send an error response and return False.


Handle a single HTTP request.

You normally don’t need to override this method; see the class __doc__ string for information on how to handle specific HTTP commands such as GET and POST.


Return the current time formatted for logging.

log_error(format, *args)

Log an error.

This is called when a request cannot be fulfilled. By default it passes the message on to log_message().

Arguments are the same as for log_message().

XXX This should go to the separate error log.

log_message(*args, **kwargs)

Log an arbitrary message.

This is used by all other logging functions. Override it if you have specific logging wishes.

The first argument, FORMAT, is a format string for the message to be logged. If the format string contains any % escapes requiring parameters, they should be specified as subsequent arguments (it’s just like printf!).

The client ip and current date/time are prefixed to every message.

log_request(*args, **kwargs)

Log an accepted request.

This is called by send_response().

monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']

Parse a request (internal).

The request should be stored in self.raw_requestline; the results are in self.command, self.path, self.request_version and self.headers.

Return True for success, False for failure; on failure, any relevant error response has already been sent back.

protocol_version = 'HTTP/1.0'
rbufsize = -1
responses = {<HTTPStatus.CONTINUE: 100>: ('Continue', 'Request received, please continue'), <HTTPStatus.SWITCHING_PROTOCOLS: 101>: ('Switching Protocols', 'Switching to new protocol; obey Upgrade header'), <HTTPStatus.PROCESSING: 102>: ('Processing', ''), <HTTPStatus.OK: 200>: ('OK', 'Request fulfilled, document follows'), <HTTPStatus.CREATED: 201>: ('Created', 'Document created, URL follows'), <HTTPStatus.ACCEPTED: 202>: ('Accepted', 'Request accepted, processing continues off-line'), <HTTPStatus.NON_AUTHORITATIVE_INFORMATION: 203>: ('Non-Authoritative Information', 'Request fulfilled from cache'), <HTTPStatus.NO_CONTENT: 204>: ('No Content', 'Request fulfilled, nothing follows'), <HTTPStatus.RESET_CONTENT: 205>: ('Reset Content', 'Clear input form for further input'), <HTTPStatus.PARTIAL_CONTENT: 206>: ('Partial Content', 'Partial content follows'), <HTTPStatus.MULTI_STATUS: 207>: ('Multi-Status', ''), <HTTPStatus.ALREADY_REPORTED: 208>: ('Already Reported', ''), <HTTPStatus.IM_USED: 226>: ('IM Used', ''), <HTTPStatus.MULTIPLE_CHOICES: 300>: ('Multiple Choices', 'Object has several resources -- see URI list'), <HTTPStatus.MOVED_PERMANENTLY: 301>: ('Moved Permanently', 'Object moved permanently -- see URI list'), <HTTPStatus.FOUND: 302>: ('Found', 'Object moved temporarily -- see URI list'), <HTTPStatus.SEE_OTHER: 303>: ('See Other', 'Object moved -- see Method and URL list'), <HTTPStatus.NOT_MODIFIED: 304>: ('Not Modified', 'Document has not changed since given time'), <HTTPStatus.USE_PROXY: 305>: ('Use Proxy', 'You must use proxy specified in Location to access this resource'), <HTTPStatus.TEMPORARY_REDIRECT: 307>: ('Temporary Redirect', 'Object moved temporarily -- see URI list'), <HTTPStatus.PERMANENT_REDIRECT: 308>: ('Permanent Redirect', 'Object moved permanently -- see URI list'), <HTTPStatus.BAD_REQUEST: 400>: ('Bad Request', 'Bad request syntax or unsupported method'), <HTTPStatus.UNAUTHORIZED: 401>: ('Unauthorized', 'No permission -- see authorization schemes'), <HTTPStatus.PAYMENT_REQUIRED: 402>: ('Payment Required', 'No payment -- see charging schemes'), <HTTPStatus.FORBIDDEN: 403>: ('Forbidden', 'Request forbidden -- authorization will not help'), <HTTPStatus.NOT_FOUND: 404>: ('Not Found', 'Nothing matches the given URI'), <HTTPStatus.METHOD_NOT_ALLOWED: 405>: ('Method Not Allowed', 'Specified method is invalid for this resource'), <HTTPStatus.NOT_ACCEPTABLE: 406>: ('Not Acceptable', 'URI not available in preferred format'), <HTTPStatus.PROXY_AUTHENTICATION_REQUIRED: 407>: ('Proxy Authentication Required', 'You must authenticate with this proxy before proceeding'), <HTTPStatus.REQUEST_TIMEOUT: 408>: ('Request Timeout', 'Request timed out; try again later'), <HTTPStatus.CONFLICT: 409>: ('Conflict', 'Request conflict'), <HTTPStatus.GONE: 410>: ('Gone', 'URI no longer exists and has been permanently removed'), <HTTPStatus.LENGTH_REQUIRED: 411>: ('Length Required', 'Client must specify Content-Length'), <HTTPStatus.PRECONDITION_FAILED: 412>: ('Precondition Failed', 'Precondition in headers is false'), <HTTPStatus.REQUEST_ENTITY_TOO_LARGE: 413>: ('Request Entity Too Large', 'Entity is too large'), <HTTPStatus.REQUEST_URI_TOO_LONG: 414>: ('Request-URI Too Long', 'URI is too long'), <HTTPStatus.UNSUPPORTED_MEDIA_TYPE: 415>: ('Unsupported Media Type', 'Entity body in unsupported format'), <HTTPStatus.REQUESTED_RANGE_NOT_SATISFIABLE: 416>: ('Requested Range Not Satisfiable', 'Cannot satisfy request range'), <HTTPStatus.EXPECTATION_FAILED: 417>: ('Expectation Failed', 'Expect condition could not be satisfied'), <HTTPStatus.MISDIRECTED_REQUEST: 421>: ('Misdirected Request', 'Server is not able to produce a response'), <HTTPStatus.UNPROCESSABLE_ENTITY: 422>: ('Unprocessable Entity', ''), <HTTPStatus.LOCKED: 423>: ('Locked', ''), <HTTPStatus.FAILED_DEPENDENCY: 424>: ('Failed Dependency', ''), <HTTPStatus.UPGRADE_REQUIRED: 426>: ('Upgrade Required', ''), <HTTPStatus.PRECONDITION_REQUIRED: 428>: ('Precondition Required', 'The origin server requires the request to be conditional'), <HTTPStatus.TOO_MANY_REQUESTS: 429>: ('Too Many Requests', 'The user has sent too many requests in a given amount of time ("rate limiting")'), <HTTPStatus.REQUEST_HEADER_FIELDS_TOO_LARGE: 431>: ('Request Header Fields Too Large', 'The server is unwilling to process the request because its header fields are too large'), <HTTPStatus.INTERNAL_SERVER_ERROR: 500>: ('Internal Server Error', 'Server got itself in trouble'), <HTTPStatus.NOT_IMPLEMENTED: 501>: ('Not Implemented', 'Server does not support this operation'), <HTTPStatus.BAD_GATEWAY: 502>: ('Bad Gateway', 'Invalid responses from another server/proxy'), <HTTPStatus.SERVICE_UNAVAILABLE: 503>: ('Service Unavailable', 'The server cannot process the request due to a high load'), <HTTPStatus.GATEWAY_TIMEOUT: 504>: ('Gateway Timeout', 'The gateway server did not receive a timely response'), <HTTPStatus.HTTP_VERSION_NOT_SUPPORTED: 505>: ('HTTP Version Not Supported', 'Cannot fulfill request'), <HTTPStatus.VARIANT_ALSO_NEGOTIATES: 506>: ('Variant Also Negotiates', ''), <HTTPStatus.INSUFFICIENT_STORAGE: 507>: ('Insufficient Storage', ''), <HTTPStatus.LOOP_DETECTED: 508>: ('Loop Detected', ''), <HTTPStatus.NOT_EXTENDED: 510>: ('Not Extended', ''), <HTTPStatus.NETWORK_AUTHENTICATION_REQUIRED: 511>: ('Network Authentication Required', 'The client needs to authenticate to gain network access')}
send_error(code, message=None, explain=None)

Send and log an error reply.

Arguments are * code: an HTTP error code

3 digits

  • message: a simple optional 1 line reason phrase.

    *( HTAB / SP / VCHAR / %x80-FF ) defaults to short entry matching the response code

  • explain: a detailed message defaults to the long entry

    matching the response code.

This sends an error response (so it must be called before any output has been generated), logs the error, and finally sends a piece of HTML explaining the error to the user.

send_header(keyword, value)

Send a MIME header to the headers buffer.

send_response(code, message=None)

Add the response header to the headers buffer and log the response code.

Also send two standard headers with the server software version and the current date.

send_response_only(code, message=None)

Send the response header only.

server_version = 'BaseHTTP/0.6'
sys_version = 'Python/3.7.9'
timeout = None

Return the server software version string.

wbufsize = 0
weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']