This is a very basis use case, where you can get the idea how to integrate ChatGPT with Pega.
Demo video:
Login to ChtGPT website using the below URL
https://platform.openai.com/playground
![](https://mypegapoc.com/wp-content/uploads/2023/03/image.png)
Sign up and create an account
Continue – Then you will receive an email for verification. Then login with your id and password.
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-1.png)
Now you click the account icon, Personal on top right corner, you will get View API keys
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-2.png)
Click View API keys
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-3.png)
Click- Create new secret key
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-4.png)
Now go to the playground tab and click view code
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-5.png)
Now login to Pega
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-6.png)
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-7.png)
Enter the following details:
Enter Name : Chat GPT Integration
Enter Endpoint URL :(https://api.openai.com/v1/completions)
Add Headers: Authorization
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-8.png)
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-9.png)
Add a REST response
Enter Authorization value (Note: Add the keyword Bearer before API Key) From Chat GPT
Enter Name : Chat GPT Integration
Enter Endpoint URL :(https://api.openai.com/v1/completions)
Add Headers: Authorization
Bearer sk-dPa**********************************HgoDWPqLibFnJ
Request body:
{
“model”: “text-davinci-003”,
“prompt”: “What is Pega CDH”,
“temperature”: 0.7,
“max_tokens”: 256,
“top_p”: 1,
“frequency_penalty”: 0,
“presence_penalty”: 0
}
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-10.png)
Note:: You should get the response and if you get error — just create a new key and copy the json from the site- do not change it manually.
In general you should get the below response
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-11.png)
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-12.png)
Click – Next
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-13.png)
Click – Create
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-14.png)
Now open the D_ChatGPTIntegration
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-15.png)
Add a parameter Question
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-16.png)
Go to the Data source
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-17.png)
Open Request Data transform <ChatGPTIntegrationRequestPOST>
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-18.png)
Go to the parameters tab and add a parameter Question
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-19.png)
Now change the Request Data Transform – change the prompt
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-20.png)
Now go to the Data Page <D_ChatGPTIntegration> and Run it
You will see the data within the choices tag
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-21.png)
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-22.png)
Now lets create a case type <ChatGPTIntegration>
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-23.png)
Add to fields
Question
Answer
Create a Data Transform
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-24.png)
Primary.Answer = D_ChatGPTIntegration[Question:Param.Question].choices(1).text
Parameters tab – Question
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-25.png)
Parameters
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-26.png)
Now go to the section add a button
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-27.png)
Add the details in the Submit button
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-28.png)
Run the case <ChatGPTIntegration>
In the question, I wrote ‘write something’ – In the Answer – ChatGPT replied. Please check the demo video at the start of the blog.
![](https://mypegapoc.com/wp-content/uploads/2023/03/image-29.png)
This is the end of this article. Hope this will help you to achieve the integration with ChatGPT. Now you can do other use cases as well.