Hello everyone! Today, we will explore an example of using ChatGPT in UiPath Studio. Let’s get started!
First, drag and drop the Sequence activity and connect it with the Start node to make it the start of the workflow.
To use ChatGPT in UiPath, you will need to install a package named ‘internal.labs.gpt.activities’. Double-click on the Sequence activity and drag and drop the Input Dialog activity inside it.
In the Title section, provide a value as ‘Select’. In the Label section, provide a value as ‘Select option’.
Select the input type as ‘Multiple Choice’. In the Input Options section, provide questions separated by semicolons and enclosed in quotes.
In the Value section, create a variable by pressing Ctrl + K and provide the name as ‘choice’.
Next, drag and drop the Read Text File activity and provide the file name in quotes, which is ‘questions.txt’.
The ‘questions.txt’ is a text file that I have created inside the UiPath project panel. It contains data in key-value pairs enclosed in curly brackets.
To store the contents of the file, create a variable named ‘read’ in the Output section.
Next, drag and drop the Ask GPT activity and provide the text to extract as the stored content of the text file, which is ‘read’.
In the Question List section, provide the same questions as mentioned above, but this time each question must be enclosed in double quotes and separated by commas. Then, enclose all the questions in curly brackets.
To store the output, create a list variable named ‘op’ in the Response List section.
Next, to select the appropriate answer from the output list, we will use the Switch activity. Change the Type Argument of the Switch activity to string.
In the Expression section, provide the value as ‘choice’.
We will create ‘4K’ statements for each case value. Type the question in order and drag and drop the Assign activity inside each case.
In the Save To section, provide a string variable ‘op2’ and in the Value To Save, provide the response list variable name, which is ‘op’, followed by the index of the question number and the field that we need to return, which is ‘answer’.
Continue this process for all questions by just changing the question and the index number of that question.
In the Default section, drag and drop a Message Box activity and type the text as ‘Option does not exist’.
Next, to display the output, drag and drop a Message Box activity outside the Switch activity and type the text as ‘Answer is ’ + variable ‘op2’.
Finally, click on ‘Run File’ from the ‘Debug’ dropdown to execute the workflow.
That’s it! You have successfully used ChatGPT in UiPath Studio. If you have any questions or need further assistance, feel free to ask.
If you found the content of today’s video helpful, make sure to like, share, and subscribe to our channel for more exciting content!