Using ChatGPT In RPA

Explore how integrating ChatGPT in RPA enhances your automation processes, enabling intelligent conversational interfaces that streamline workflows, improve user interactions, and drive efficiency. We can leverage the natural language processing capabilities of the OpenAI model to interact with applications and systems. In RPA tool like UiPath, we can use ChatGPT to understand input from users/systems and extract key information from it. Bot can then execute specified actions such as interacting with applications, filling forms, or making decisions etc.

As a part of this demo, we will use ChatGPT text completion API with UiPath and go through various steps of workflow development. We assume that you already have free UiPath studio community version installed and connected to cloud orchestrator with required development licensed assigned.

Register and get OpenAI API Key

You can visit the OpenAI website and sign up for an account and follow the steps to get the required API key. It is recommended to test the sample API in postman before starting the development in UiPath studio. Here we will use “https://api.openai.com/v1/chat/completions” as an API endpoint and pass required information in json body.

Install UiPath Required Packages

Launch UiPath Studio and go to the Manage Packages window (Home > Manage Packages). In the Official or All Packages tab, you should search for “UiPath.Web.Activities.” and install the package.

Create UiPath Workflow

Create a new project in studio and add HTTP request activity in your workflow. For passing request payload in JSON, we will write the request in text file and convert into JSON object. As an example, use the following JSON payload in text file for passing to OpenAI API.

{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "USD to EUR rate today"
}
]
}

Here we are asking ChatGPT for current USD to EUR exchange rate. We will first read text file and convert it to JSON object and pass it to HTTP request activity and extract the output from response payload. The whole workflow in UiPath look like this

UiPath workflow for using chatgpt in rpa

Configure HTTP Request activity

In the properties panel, configure the HTTP Request activity: you can set the Endpoint property to “https://api.openai.com/v1/chat/completions”. Set the Method property to POST and add an Authorization header with the value “Bearer YOUR_API_KEY,”. Replacing “YOUR_API_KEY” with your actual OpenAI API key. Add a Content-Type header with the value “application/json.” as shown below

UiPath configure http request activity for calling ChatGPT OpenAPI.

We will pass the JSON object created from text file in the body of http request activity under options in properties panel.

Handle the Response

We need to handle the output of the HTTP Request activity to get extract required information from response payload. We have parsed the JSON response to extract the generated text using vOutJsonObj.item(“choices”)(0).item(“message”).Item(“content”) .ToString and vOutJsonObj is the output http request activity.

Running the workflow and way forward

Now you can run UiPath workflow to send a request to the OpenAI API and get the generated text. We have used message box activity to display the response from chatgpt. It is recommended to handle the errors in your workflow and comply with OpenAI’s usage policies and terms of service. OpenAI provides specific guidance for using GPT-3 or other models, please refer to the documentation for detailed information.

Using ChatGPT In RPA

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top