GPT Actions library - Confluence

2024年7月31日
在 Github 中打开

这个特定的 GPT Action 概述了如何连接到 Confluence,Atlassian 的协作和文档平台。此 Action 接收用户的问题,扫描相关的 Confluence 空间和页面以收集必要的信息,然后形成响应以回答用户的问题。本操作指南不涉及直接从 ChatGPT 更新 Confluence 中的内容,但从技术上来说,通过额外的 Actions 和作用域可以实现。

价值

用户现在可以利用 ChatGPT 的自然语言能力直接连接到 Confluence,从而实现与其组织知识库的无缝交互。

示例用例

  • 知识工作者:轻松从 Confluence 页面和空间检索信息,以回答问题或收集报告和演示文稿的详细信息。
  • 项目经理:快速访问存储在 Confluence 中的项目文档和更新,而无需手动搜索页面。
  • 客户支持团队:通过从 Confluence 知识库中提取相关信息,为客户咨询提供准确及时的响应。
  • 所有用户:更深入地了解公司范围内的文档、政策和程序,从而加强协作和知识共享。

在开始之前,请确保在您的应用程序环境中完成以下步骤

  • 确保您有权在 Atlassian 开发者门户中创建应用
  • 确定您希望 GPT 执行哪些交互(搜索、读取、编辑等)

创建自定义 GPT 后,将以下文本复制到“Instructions(指令)”面板中。有问题?请查看入门示例,了解此步骤的详细工作原理。

You are a "Confluence Savant", equipped with the ability to search our company's Product Wiki in Confluence to answer product-related questions.

You must ALWAYS perform the "getAccessibleResources" Action first to get the "cloudid" value you will need in subsequent Actions.

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.

    - 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.
    - 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.
    - 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.
    - 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.
    - 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.

    Here is an example of how you might respond to a query:

    User: "What are the latest features of our XYZ product?"
    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]."

Remember, your goal is to provide helpful, accurate, and relevant information to the user's query by effectively leveraging the Confluence Product Wiki.

创建自定义 GPT 后,将以下文本复制到“Actions(操作)”面板中。有问题?请查看入门示例,了解此步骤的详细工作原理。

openapi: 3.1.0
info:
  title: Atlassian API
  description: This API provides access to Atlassian resources through OAuth token authentication.
  version: 1.0.0
servers:
  - url: https://api.atlassian.com
    description: Main API server
paths:
  /oauth/token/accessible-resources:
    get:
      operationId: getAccessibleResources
      summary: Retrieves accessible resources for the authenticated user.
      description: This endpoint retrieves a list of resources the authenticated user has access to, using an OAuth token.
      security:
        - bearerAuth: []
      responses:
        '200':
          description: A JSON array of accessible resources.
          content:
            application/json:
              schema: 
                $ref: '#/components/schemas/ResourceArray'
  /ex/confluence/{cloudid}/wiki/rest/api/search:
    get:
      operationId: performConfluenceSearch
      summary: Performs a search in Confluence based on a query.
      description: This endpoint allows searching within Confluence using the CQL (Confluence Query Language).
      parameters:
        - in: query
          name: cql
          required: true
          description: The Confluence Query Language expression to evaluate.
          schema:
            type: string
        - in: path
          name: cloudid
          required: true
          schema:
            type: string
          description: The cloudid retrieved from the getAccessibleResources Action
        - in: query
          name: cqlcontext
          description: The context to limit the search, specified as JSON.
          schema:
            type: string
        - in: query
          name: expand
          description: A comma-separated list of properties to expand on the search result.
          schema:
            type: string
      responses:
        '200':
          description: A list of search results matching the query.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResults'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    ResourceArray:
      type: array
      items:
        $ref: '#/components/schemas/Resource'
    Resource:
      type: object
      required:
        - id
        - name
        - type
      properties:
        id:
          type: string
          description: The unique identifier for the resource.
        name:
          type: string
          description: The name of the resource.
        type:
          type: string
          description: The type of the resource.
    SearchResults:
      type: object
      properties:
        results:
          type: array
          items:
            $ref: '#/components/schemas/SearchResult'
    SearchResult:
      type: object
      properties:
        id:
          type: string
          description: The unique identifier of the content.
        title:
          type: string
          description: The title of the content.
        type:
          type: string
          description: The type of the content (e.g., page, blog post).
        space:
          type: object
          properties:
            id:
              type: string
              description: The space ID where the content is located.
            name:
              type: string
              description: The name of the space.

以下是关于设置与此第三方应用程序进行身份验证的说明。有问题?请查看入门示例,了解此步骤的详细工作原理。

在 ChatGPT 中设置身份验证之前,请确保在 Atlassian 开发者门户中完成以下步骤以创建您的 Confluence 应用

  1. 选择“Create(创建)”下拉菜单
  2. 选择 “OAuth 2.0 integration(OAuth 2.0 集成)”
  3. 给应用命名,同意条款,然后点击“Create(创建)”
  4. 在左侧菜单中选择“Distribution(分发)”,然后点击“Edit(编辑)”
  5. 将单选按钮更改为“Sharing(共享)”
  6. 填写必填字段并点击“Save Changes(保存更改)”
  7. 在左侧菜单中选择“Permissions(权限)”
  8. 添加您想要包含的作用域(例如,User identity API 和 Confluence API,以便应用可以知道用户有权访问的内容并从 Confluence 获取信息)
  9. 在左侧菜单中选择“Authorization(授权)”
  10. 在 OAuth 2.0 的行中,点击“Action(操作)”下的“Add(添加)”
  11. 输入来自您的 GPT 的回调 URL(注意:您可能需要先添加一个占位符,并在您的 GPT 中创建 Action 和 OAuth 后重新访问此步骤,以便您拥有最终的回调 URL)
  12. 在左侧菜单下选择“Settings(设置)”
  13. 复制您的 Client ID(客户端 ID)和 Secret(密钥)以便在 GPT 中设置 OAuth 时使用

confluence_gpt.png

在 ChatGPT 中,点击“Authentication(身份验证)”,然后选择 “OAuth”。输入以下信息。

  • Client ID(客户端 ID):使用上述步骤中的 Client ID
  • Client Secret(客户端密钥):使用上述步骤中的 Client Secret
  • Authorization URL(授权 URL): https://auth.atlassian.com/authorize
  • Token URL(令牌 URL): https://auth.atlassian.com/oauth/token
  • Scope(作用域): read:confluence-content.all search:confluence
  • Token(令牌): 默认 (POST)

在 ChatGPT 中设置身份验证后,请按照应用程序中的以下步骤完成 Action。

  • 从 GPT Action 复制回调 URL
  • 在“Authorized redirect URIs(授权重定向 URI)”(请参见上面的屏幕截图)中,添加您的回调 URL
  • Callback URL Error(回调 URL 错误): 如果您在 ChatGPT 中收到回调 URL 错误,请密切注意上面的屏幕截图。您需要将回调 URL 直接添加到您的 Confluence 应用中,以便 Action 可以正确进行身份验证
  • Schema calls the wrong project or dataset(架构调用了错误的项目或数据集): 如果 ChatGPT 调用了错误的项目或数据集,请考虑更新您的指令,使其更明确地说明 (a) 应调用哪个项目/数据集,或 (b) 要求用户在运行查询之前提供确切的详细信息
  • Looping Actions(循环 Action): 您可能没有为您的应用程序提供必要的 scope/permissions(作用域/权限)以实现其预期目的

您希望我们优先考虑哪些集成?我们的集成中是否存在错误?在我们的 github 中提交 PR 或 issue,我们将进行查看。