mirror of
https://github.com/openai/openai-cookbook
synced 2024-11-11 13:11:02 +00:00
Create gpt_action_confluence.ipynb (#1335)
Co-authored-by: Aaron Wilkowitz <157151487+aaronwilkowitz-openai@users.noreply.github.com>
This commit is contained in:
parent
dc341ee67a
commit
b0610faa09
418
examples/chatgpt/gpt_actions_library/gpt_action_confluence.ipynb
Normal file
418
examples/chatgpt/gpt_actions_library/gpt_action_confluence.ipynb
Normal file
@ -0,0 +1,418 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# GPT Action Library: Confluence"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Introduction"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"This page provides an instruction & guide for developers building a GPT Action for a specific application. Before you proceed, make sure to first familiarize yourself with the following information: \n",
|
||||
"- [Introduction to GPT Actions](https://platform.openai.com/docs/actions)\n",
|
||||
"- [Introduction to GPT Actions Library](https://platform.openai.com/docs/actions/actions-library)\n",
|
||||
"- [Example of Building a GPT Action from Scratch](https://platform.openai.com/docs/actions/getting-started)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"This particular GPT Action provides an overview of how to connect to **Confluence**, Atlassian's collaboration and documentation platform. This Action takes a user’s question, scans the relevant Confluence spaces and pages to gather the necessary information, then formulates a response to answer the user’s question. This cookbook does not address updating content in Confluence directly from ChatGPT, but it is technically feasible to accomplish with additional Actions and scopes."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Value + Example Business Use Cases"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Value**\n",
|
||||
"\n",
|
||||
"Users can now leverage ChatGPT's natural language capability to connect directly to Confluence, enabling seamless interaction with their organization's knowledge base.\n",
|
||||
"\n",
|
||||
"**Example Use Cases**\n",
|
||||
"- **Knowledge Workers**: Easily retrieve information from Confluence pages and spaces to answer questions or gather details for reports and presentations.\n",
|
||||
"- **Project Managers**: Quickly access project documentation and updates stored in Confluence without manually searching through pages.\n",
|
||||
"- **Customer Support Teams**: Provide accurate and timely responses to customer inquiries by pulling relevant information from the Confluence knowledge base.\n",
|
||||
"- **All Users**: Gain more visibility into company-wide documentation, policies, and procedures, enhancing collaboration and knowledge sharing."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Application Information"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Application Key Links"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Check out these links from the application before you get started:\n",
|
||||
"- Application Website: https://developer.atlassian.com/console/myapps/ \n",
|
||||
"- Application API Documentation: https://developer.atlassian.com/cloud/confluence/rest/v2/intro/#about"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Application Prerequisites"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Before you get started, make sure you go through the following steps in your application environment:\n",
|
||||
"- Ensure you have permissions to create an App in the Atlassian Developer Portal\n",
|
||||
"- Determine what interactions you would like your GPT to take (search, read, edit, etc.)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## ChatGPT Steps"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Custom GPT Instructions "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Once you've created a Custom GPT, copy the text below in the Instructions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"vscode": {
|
||||
"languageId": "plaintext"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"You are a \"Confluence Savant\", equipped with the ability to search our company's Product Wiki in Confluence to answer product-related questions.\n",
|
||||
"\n",
|
||||
"You must ALWAYS perform the \"getAccessibleResources\" Action first to get the \"cloudid\" value you will need in subsequent Actions.\n",
|
||||
"\n",
|
||||
"Your job is to provide accurate and detailed responses by retrieving information from the Product Wiki. Your responses should be clear, concise, and directly address the question asked. You have the capability to execute an action named \"performConfluenceSearch\" that allows you to search for content within our Confluence Product Wiki using specific terms or phrases related to the user's question.\n",
|
||||
"\n",
|
||||
" - When you receive a query about product information, use the \"performConfluenceSearch\" action to retrieve relevant content from the Product Wiki. Formulate your search query based on the user's question, using specific keywords or phrases to find the most pertinent information.\n",
|
||||
" - Once you receive the search results, review the content to ensure it matches the user's query. If necessary, refine your search query to retrieve more accurate results.\n",
|
||||
" - Provide a response that synthesizes the information from the Product Wiki, clearly answering the user's question. Your response should be easy to understand and directly related to the query.\n",
|
||||
" - If the query is complex or requires clarification, ask follow-up questions to the user to refine your understanding and improve the accuracy of your search.\n",
|
||||
" - If the information needed to answer the question is not available in the Product Wiki, inform the user and guide them to where they might find the answer, such as contacting a specific department or person in the company.\n",
|
||||
"\n",
|
||||
" Here is an example of how you might respond to a query:\n",
|
||||
"\n",
|
||||
" User: \"What are the latest features of our XYZ product?\"\n",
|
||||
" You: \"The latest features of the XYZ product, as detailed in our Product Wiki, include [feature 1], [feature 2], and [feature 3]. These features were added in the recent update to enhance [specific functionalities]. For more detailed information, you can refer to the Product Wiki page [link to the specific Confluence page].\"\n",
|
||||
"\n",
|
||||
"Remember, your goal is to provide helpful, accurate, and relevant information to the user's query by effectively leveraging the Confluence Product Wiki.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### OpenAPI Schema "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Once you've created a Custom GPT, copy the text below in the Actions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"vscode": {
|
||||
"languageId": "yaml"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"openapi: 3.1.0\n",
|
||||
"info:\n",
|
||||
" title: Atlassian API\n",
|
||||
" description: This API provides access to Atlassian resources through OAuth token authentication.\n",
|
||||
" version: 1.0.0\n",
|
||||
"servers:\n",
|
||||
" - url: https://api.atlassian.com\n",
|
||||
" description: Main API server\n",
|
||||
"paths:\n",
|
||||
" /oauth/token/accessible-resources:\n",
|
||||
" get:\n",
|
||||
" operationId: getAccessibleResources\n",
|
||||
" summary: Retrieves accessible resources for the authenticated user.\n",
|
||||
" description: This endpoint retrieves a list of resources the authenticated user has access to, using an OAuth token.\n",
|
||||
" security:\n",
|
||||
" - bearerAuth: []\n",
|
||||
" responses:\n",
|
||||
" '200':\n",
|
||||
" description: A JSON array of accessible resources.\n",
|
||||
" content:\n",
|
||||
" application/json:\n",
|
||||
" schema: \n",
|
||||
" $ref: '#/components/schemas/ResourceArray'\n",
|
||||
" /ex/confluence/{cloudid}/wiki/rest/api/search:\n",
|
||||
" get:\n",
|
||||
" operationId: performConfluenceSearch\n",
|
||||
" summary: Performs a search in Confluence based on a query.\n",
|
||||
" description: This endpoint allows searching within Confluence using the CQL (Confluence Query Language).\n",
|
||||
" parameters:\n",
|
||||
" - in: query\n",
|
||||
" name: cql\n",
|
||||
" required: true\n",
|
||||
" description: The Confluence Query Language expression to evaluate.\n",
|
||||
" schema:\n",
|
||||
" type: string\n",
|
||||
" - in: path\n",
|
||||
" name: cloudid\n",
|
||||
" required: true\n",
|
||||
" schema:\n",
|
||||
" type: string\n",
|
||||
" description: The cloudid retrieved from the getAccessibleResources Action\n",
|
||||
" - in: query\n",
|
||||
" name: cqlcontext\n",
|
||||
" description: The context to limit the search, specified as JSON.\n",
|
||||
" schema:\n",
|
||||
" type: string\n",
|
||||
" - in: query\n",
|
||||
" name: expand\n",
|
||||
" description: A comma-separated list of properties to expand on the search result.\n",
|
||||
" schema:\n",
|
||||
" type: string\n",
|
||||
" responses:\n",
|
||||
" '200':\n",
|
||||
" description: A list of search results matching the query.\n",
|
||||
" content:\n",
|
||||
" application/json:\n",
|
||||
" schema:\n",
|
||||
" $ref: '#/components/schemas/SearchResults'\n",
|
||||
"components:\n",
|
||||
" securitySchemes:\n",
|
||||
" bearerAuth:\n",
|
||||
" type: http\n",
|
||||
" scheme: bearer\n",
|
||||
" bearerFormat: JWT\n",
|
||||
" schemas:\n",
|
||||
" ResourceArray:\n",
|
||||
" type: array\n",
|
||||
" items:\n",
|
||||
" $ref: '#/components/schemas/Resource'\n",
|
||||
" Resource:\n",
|
||||
" type: object\n",
|
||||
" required:\n",
|
||||
" - id\n",
|
||||
" - name\n",
|
||||
" - type\n",
|
||||
" properties:\n",
|
||||
" id:\n",
|
||||
" type: string\n",
|
||||
" description: The unique identifier for the resource.\n",
|
||||
" name:\n",
|
||||
" type: string\n",
|
||||
" description: The name of the resource.\n",
|
||||
" type:\n",
|
||||
" type: string\n",
|
||||
" description: The type of the resource.\n",
|
||||
" SearchResults:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" results:\n",
|
||||
" type: array\n",
|
||||
" items:\n",
|
||||
" $ref: '#/components/schemas/SearchResult'\n",
|
||||
" SearchResult:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" id:\n",
|
||||
" type: string\n",
|
||||
" description: The unique identifier of the content.\n",
|
||||
" title:\n",
|
||||
" type: string\n",
|
||||
" description: The title of the content.\n",
|
||||
" type:\n",
|
||||
" type: string\n",
|
||||
" description: The type of the content (e.g., page, blog post).\n",
|
||||
" space:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" id:\n",
|
||||
" type: string\n",
|
||||
" description: The space ID where the content is located.\n",
|
||||
" name:\n",
|
||||
" type: string\n",
|
||||
" description: The name of the space."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Authentication Instructions"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Below are instructions on setting up authentication with this 3rd party application. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Pre-Action Steps"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Before you set up authentication in ChatGPT, make sure you go through the following steps within the Atlassian Developer portal to create your Confluence app:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"1. Select the Create drop-down\n",
|
||||
"2. Choose OAuth 2.0 integration\n",
|
||||
"3. Give a name, agree to terms, and click Create\n",
|
||||
"4. Select \"Distribution\" on the left-hand menu and click “Edit”\n",
|
||||
"5. Change radio button to \"Sharing\"\n",
|
||||
"6. Fill out required fields and Save Changes\n",
|
||||
"7. Select \"Permissions\" on the left-hand menu\n",
|
||||
"8. Add in the scopes you would like to include (e.g., User identity API and Confluence API so that the app can know what a user has access to and fetch from Confluence)\n",
|
||||
"9. Select \"Authorization\" on the left-hand menu\n",
|
||||
"10. Click \"Add\" under Action in the row for OAuth 2.0\n",
|
||||
"11. Enter the callback URL from your GPT (note: you may need to add a placeholder for now and revisit this once you have created the Action and OAuth in your GPT so that you have the final callback URL)\n",
|
||||
"12. Select \"Settings\" under the left-hand menu\n",
|
||||
"13. Copy your Client ID and Secret for us in OAuth setup in GPT\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"![confluence_gpt.png](../../../images/confluence_gpt.png)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### In ChatGPT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"In ChatGPT, click on \"Authentication\" and choose **\"OAuth\"**. Enter in the information below. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"- **Client ID**: use Client ID from steps above \n",
|
||||
"- **Client Secret**: use Client Secret from steps above\n",
|
||||
"- **Authorization URL**: https://auth.atlassian.com/authorize\n",
|
||||
"- **Token URL**: https://auth.atlassian.com/oauth/token \n",
|
||||
"- **Scope**: read:confluence-content.all search:confluence\n",
|
||||
"- **Token**: Default (POST)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Post-Action Steps"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Once you've set up authentication in ChatGPT, follow the steps below in the application to finalize the Action. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"- Copy the callback URL from the GPT Action\n",
|
||||
"- In the “Authorized redirect URIs” (see screenshot above), add your callback URL \n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### FAQ & Troubleshooting"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"- *Callback URL Error:* If you get a callback URL error in ChatGPT, pay close attention to the screenshot above. You need to add the callback URL directly into your Confluence app for the action to authenticate correctly\n",
|
||||
"- *Schema calls the wrong project or dataset:* If ChatGPT calls the wrong project or dataset, consider updating your instructions to make it more explicit either (a) which project / dataset should be called or (b) to require the user provide those exact details before it runs the query\n",
|
||||
"- *Looping Actions:* You may not have given the necessary scopes/permissions to your app to accomplish its intended purpose"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"*Are there integrations that you’d like us to prioritize? Are there errors in our integrations? File a PR or issue in our github, and we’ll take a look.*\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
BIN
images/confluence_gpt.png
Normal file
BIN
images/confluence_gpt.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 135 KiB |
@ -1445,3 +1445,12 @@
|
||||
tags:
|
||||
- gpt-actions-library
|
||||
- chatgpt
|
||||
|
||||
- title: GPT Actions library - Confluence
|
||||
path: examples/chatgpt/gpt_actions_library/gpt_action_confluence.ipynb
|
||||
date: 2024-07-31
|
||||
authors:
|
||||
- eszuhany-openai
|
||||
tags:
|
||||
- gpt-actions-library
|
||||
- chatgpt
|
||||
|
Loading…
Reference in New Issue
Block a user