- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
01-30-2023 08:01 AM - edited 02-01-2023 12:18 AM
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:
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:
Go to Flow Actions, create a new Action (I named it as ActionOnChatGPT) that has two steps.
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!
- 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
- 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.
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:
- "Update Incident Record" where incident's description is updated with a text produced by ChatGPT (over Action).
Resulting flow looks like:
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.
Hope it helps! 🙂
- 5,602 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@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.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Great tutorial, thanks!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
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
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
if the parameter is array type how should we modify the body of content?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi appli
Can you please share the screen shot of connection and credential also
