UiPath Integration with ChatGPT

#ChatGPT is in the news and creating a buzz around it. Many predicted that it is the next big thing after Google. Since ChatGPT is breaking the internet and everyone is trying to use it atleast once to do many tasks and seek fun.

In this guide we will show how you can integrate ChatGPT with UiPath by OpenAI.

ChatGPT have many different models like- List Model, Retrieve Model, Completions Model any many more.

Let’s see the demostration:-

  1. First we will use the Input Dialog activity to take the input from the user.


  1. Now we need to process the User Input , so we use the HTTP Request activity.

To use this activity, we need to install the below activity from Manage Packages.

Now,drag and drop the activity HTTP Request and click on Configure button.

Once you will click on configure button, you will see the below window.

The inputs will be configured from the Open AI ChatGPT

Lets see how to get the input from Open AI ChatGPT

  1. Open the API Reference page of OpenAI ChatGPT.

API Reference — OpenAI API

  1. Go to Authentication page and click on API Keys link to create new API key.

  1. Click on new secret key to create API key and copy the key to notepad for further use.

Note:- API key is confidential and should not be shared with anyone.

  1. We are using completion Model for this guide.

Copy the End point URL from here and paste it into Notepad.

Now, we use all the information from Notepad to the HTTP request input.

Once you are done, then click on ok.

Now, we have to set the pass the UserInput into the HTTP request activity for processing for which we will use the property Body & Body Format and store the response output into the variable.

Change the body format to application/json.

As the body format is in json , so we have to convert the input into json.so we will a create a new Variable “ChatGPTInput” of type JObject and initialize the variable.


Now we will use an assign activity and pass the userinput to the Completion parameters.


Pass the JObject variable into the Body.

Store the Output into ChatGPTOutput variable.

Now, lets print the output by using the Write Line activity.


Message box-

This output contain so many details , but we just need the output. So we will decode this json output into the relevant output.

  1. We will use the Deserialize Json activity to decode the json. We will pass the output variable i.e ChatGPTOutput as an input and change the variable type to JObject.


Now, we will use the Write line activity to print the output.

We can see now the output is converted into the Json format which is readable to the user.

As we are interested only in the output and not the rest of the details. so we can see the text in the below image contains our output which is in Array Choices. so, we deserialize this array.

We can see now the output is converted into the Json format which is readable to the user.

We can see now the output is converted into the Json format which is readable to the user.

  1. Use Deserialize Json Array activity and pass the array name.


  1. We will again use the write line to see the result.




  1. As there is only curly braces inside the Square bracket, it means there is only 1 element in an array i.e at index 0 and then we need to get the outout from text, so we will use the below methos to get the result.


Now, finally lets run the workflow.


I hope you like it !

Happy Automation :slight_smile:


Thanks @Nitya1 for this useful information :slight_smile:


Great work @Nitya1 it will be helpful for all.


Nice! Thanks for sharing! :blush:


Hi @Nitya1, Excellent ! Thanks for sharing! :blush:


Thank you for the nice writeup with pictures. For longer answers, the message is cut off. How to get the full message from the API?

Its not providing long answers with the integration.

Nice! Thanks for sharing

Having the same issue. Looks like scraping from website might be the temporary solution.

The body value is not working for me. can u pls share ur xaml if possible after removing your API key