Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Appli
Mega Sage

Hi All

 

You have probably tried already to communicate with a new AI tool ChatGPT (advanced chatbot). 

Of course, I also tried to ask ChatGPT various tricky questions and one of them was "how to integrate ServiceNow with ChatGPT? Do I need to use a code for that?". ChatGPT replied with a quite generic manual, confirming that writing a code is required and pointing to a need to use RestAPI with scripts, vaiables, etc.

But hey ChatGPT - why do I need to code anything there if ServiceNow provides a great OOB tools like Flow Designer? So, please see below a complete manual for introducing ServiceNow - ChatGPT integration (or, actually, an integration based on OpenAI GPT-3 API (ChatGPT is also related to GPT-3)) using LOW/NO code development approach.

 

Let me come up with a USE CASE first:

  • If caller submits an incident and its description is empty, description text has to be generated by AI tool, and provided back to the newly created incident updating it.
  • Implementation must be done in Flow Designer with no steps that require coding.
  • This is a learning exercise; it should be possible to repeat all steps from this manual in PDI (Tokyo)

 

Step 1.

Create an API key by accessing OpenAI API page. 

Create a new application in ServiceNow (usually I use App Engine Studio for that). I created "MyOpenAI" application, that will also be a spoke in Flow Designer.

Navigate to Connections & Credentials -> Credentials, create new API Key Credentials (with API key value from OpenAI), add this Credential to Credential Alias (create it first). In my case, resulting form for API key credential "ChatGPT" looks like:

 

Appli_0-1675090976104.png

 

Step 2.

Go to Flow Designer, create a new Flow (I named it as ChatGPT_Ask).

Define a trigger: New incident is created and its Description is empty:

 

Appli_13-1675092457976.png

 

Go to Flow Actions, create a new Action (I named it as ActionOnChatGPT) that has two steps.

 

Appli_11-1675092347946.png

 

Few bullet points here:

  • Action "ActionOnChatGPT" has one Input (I named it as "prompt") and one Output (named it as "Answer)
  • Rest Step: please pay attention to Request details, Headers used and Request (body) content.
    • Very important: API key is provided in the header as a reference to the credentials defined before. Key should not be set as a clear text!
              Appli_3-1675091485657.png

 

  • JSON Parser step
    • For the note: The JSON parser step is not available in the base system and requires the Integration Hub Standard Pack Installer.
    • How to use JSON parser - please watch a video: https://www.youtube.com/watch?v=3xABNbDdgXU
              Appli_4-1675091608741.png

 

  • Outputs: this is where I put a little (very very very little code 🙂 ) to return just a value of the "answer" text but not the full JSON object.

     

              Appli_10-1675092269573.png

 

Return to Flow and add two actions:

 

  • Action that you just created (in my case it is ActionOnChatGPT) where you pass a Short Description  (and some text around - just to have more fun) from the incident:
              Appli_9-1675092205151.png

 

  • "Update Incident Record" where incident's description is updated with a text produced by ChatGPT (over Action).
              Appli_8-1675092162093.png

 

Resulting flow looks like:

 

Appli_0-1675093763675.png

 

 Step 3.

Test the flow and actions inside by creating a new incident with empty Description.

After submitting an incident (I did it over Platform UI using "Save" button) with empty Description, my incident was updated itself with a description text taken from AI.

 

Appli_14-1675093101255.png

 

Hope it helps! 🙂

Comments
Grant Hulbert
ServiceNow Employee
ServiceNow Employee

@Appli Very cool and useful, indeed! A tip for other readers: this is not chatGPT. This is GPT-3 "Completions" API. Unfortunately, as of this time of this writing, chatGPT does not yet have an API.

Joel A_1
Giga Expert

Great tutorial, thanks!

Grant Hulbert
ServiceNow Employee
ServiceNow Employee

Great news, everyone, chatGPT now has a proper API, and it's even less expensive that GPT's API!

 

https://openai.com/blog/introducing-chatgpt-and-whisper-apis

Hemanth57
Tera Explorer

if the parameter is array type how should we modify the body of content?

Tejaswini Yaram
Tera Contributor

Hi appli

Can you please share the screen shot of connection and credential also

Version history
Last update:
‎02-01-2023 12:18 AM
Updated by:
Contributors