New Canvas LMS GPT Action (#1409)

Co-authored-by: pap-openai <pap@openai.com>
This commit is contained in:
joecasson-openai 2024-09-20 08:48:54 -04:00 committed by GitHub
parent ba3da24206
commit 550f6dd815
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 602 additions and 699 deletions

View File

@ -167,3 +167,8 @@ lspacagna-oai:
name: "Lee Spacagna"
website: "https://github.com/lspacagna-oai"
avatar: "https://avatars.githubusercontent.com/u/175367019"
joecasson-openai:
name: "Joe Casson"
website: "https://github.com/joecasson-openai"
avatar: "https://avatars.githubusercontent.com/u/178522625"

View File

@ -0,0 +1,593 @@
# Canvas LMS Cookbook
### Table of Contents
1. [**General App Information**](#general-app-information) - Overview of Canvas LMS, its functionality, and the role of ChatGPT's Custom Actions to enhance educational experiences through AI integration.
2. [**Authentication from ChatGPT to Canvas**](#authentication-from-chatgpt-to-canvas) - Explanation of authentication methods (OAuth and User Generated Access Tokens) for connecting ChatGPT to Canvas, with detailed instructions for setting up each option.
3. [**Sample Use Case: Student Course Assistant**](#sample-use-case-student-course-assistant) - Detailed example of using ChatGPT to assist students with course navigation, exam preparation, and personalized feedback, including specific API calls and workflows.
4. [**Other Use Cases for Consideration**](#other-use-cases-for-consideration) - Additional potential integrations using the Canvas API, such as classroom analytics and report generation.
5. [**Congratulations**](#congratulations)
## General App Information
Canvas is a widely-used Learning Management System (LMS) designed to support online learning and teaching. It offers a robust set of tools for course management, content delivery, assessments, and student collaboration. Through the [Canvas REST API](https://canvas.instructure.com/doc/api/all_resources.html), Canvas allows for extensive customization and integration with third-party applications, including AI-powered tools like ChatGPT.
ChatGPTs Custom Actions with Canvas enable educators to leverage AI to enhance course content, automate tasks, and provide personalized learning journeys for students. Examples include virtual teaching assistants based on active courses, as the capabilities are well-suited for pulling information in from Canvas to create an educational dialogue. ChatGPT with Custom Actions is not meant for automating the entire Canvas experience nor act as a replacement to many of its capabilities better suited for completion in the Canvas app.
## Authentication from ChatGPT to Canvas
For a general overview on Authentication in Custom Actions, see the [Action authentication documentation](https://platform.openai.com/docs/actions/authentication).
There are two options for authentication in Canvas: 1) OAuth and 2) User Generated Access Tokens.
- For large-scale deployments, it is required to use OAuth for Action Authentication.
- If the user is considering a single-user deployment or does not have access to Admin Settings, they may consider User Generated Access Tokens. Be aware that any request made by the action will be made using the token the user generated, so Canvas will register all requests as the user's activity and use the user's permissions to complete them.
### Implementing OAuth for Canvas
While this Canvas Cookbook does not use OAuth, any deployment with more than one user must use it. See [OAuth for Canvas Documentation](https://canvas.instructure.com/doc/api/file.oauth.html#oauth2-flow) for a detailed walkthrough.
Here are some things to keep in mind while implementing OAuth in a Canvas Custom Action:
- Access to Canvas Admin settings is required for OAuth in order to retrieve a Client ID and Client Secret.
- The Authorization URL will look like (make sure to update the Canvas Install URL): https://<canvas-install-url>/login/oauth2/auth
- The Token URL will look like (make sure to update the Canvas Install URL): ttps://<canvas-install-url>/login/oauth2/token
- Scopes may not need to be defined in the Custom Action. If the developer key does not require scopes and no scope parameter is specified, the access token will have access to all scopes. If the developer key does require scopes and no scope parameter is specified, Canvas will respond with "invalid_scope." More information on developer keys [here](https://canvas.instructure.com/doc/api/file.developer_keys.html) and endpoints [here](https://canvas.instructure.com/doc/api/file.oauth_endpoints.html#get-login-oauth2-auth).
- Token Exchange Method is Default (POST Request)
- Canvas uses the term `redirect_uri` where ChatGPT uses the term `Callback URL` for URL to complete the redirect process after successful authentication.
### Implementing authentication with User Generated Access Tokens
In some cases, it may be appropriate to use [User Generated Access Tokens](https://canvas.instructure.com/doc/api/file.oauth.html#manual-token-generation) for Custom Action authentication with Canvas. Here are the steps to follow to do so:
1. Proceed to Canvas Account Settings shown here:
![canvas_lms_settings_link.png](../../../images/canvas_lms_settings_link.png)
2. Scroll down to the List of Tokens shown here:
![canvas_lms_list_of_tokens.png](../../../images/canvas_lms_list_of_tokens.png)
3. Generate a New Token, and **store this token**. It will not be accessible later.
![canvas_lms_new_token.png](../../../images/canvas_lms_new_token.png)
## Sample Use Case: Student Course Assistant
### Overview
Assists students in navigating and understanding their courses by providing detailed information, generating personalized practice exams, and offering constructive feedback to enhance learning.
### Considerations
- Some information like the Syllabus is returned as an HTML page when requested by the API. This renders it impossible to show in ChatGPT. Instead, reference course description, modules, and the assignments to guide the user.
- Requests can be modified to retrieve specific pieces of information using the `include[]` query parameter. If you need to request specific information about a course, provide an example in the GPT instructions.
### GPT Instructions
There can be multiple ways to write these instructions. [See here](https://platform.openai.com/docs/guides/prompt-engineering) for guidance on Prompt Engineering strategies and best practices.
```
# **Context:** You support college students by providing detailed information about their courses hosted on the Canvas Learning Management System. You help them understand course content, generate practice exams based on provided materials, and offer insightful feedback to aid their learning journey. Assume the students are familiar with basic academic terminologies.
# **Instructions:**
## Scenarios
### - When the user asks for information about a specific course, follow this 5 step process:
1. Ask the user to specify the course they want assistance with and the particular area of focus (e.g., overall course overview, specific module).
2. If you do not know the Course ID for the course requested, use the listYourCourses to find the right course and corresponding ID in Canvas. If none of the courses listed returned courses that seem to match the course request, use the searchCourses to see if there are any similarly named course.
3. Retrieve the course information from Canvas using the getSingleCourse API call and the listModules API call.
4. Ask the user which module(s) they would like to focus on and use the listModuleItems to retrieve the requested module items. For any assignments, share links to them.
5. Ask if the user needs more information or if they need to prepare for an exam.
### When a user asks to take a practice test or practice exam for a specific course, follow this 6 step process:
1. Ask how many questions
2. Ask which chapters or topics they want to be tested on, provide a couple examples from the course modules in Canvas.
3. Ask 1 question at a time, be sure the questions are multiple choice (do not generate the next question until the question is answered)
4. When the user answers, tell them if its right or wrong and give a description for the correct answer
5. Ask the user if they want to export the test results and write the code to create the PDF
6. Offer additional resources and study tips tailored to the user's needs and progress, and inquire if they require further assistance with other courses or topics.
### When a user asks to create a study guide
- Format the generated study guide in a table
```
### OpenAPI Schema
- API Calls Featured
- [GET] [listYourCourses](https://canvas.instructure.com/doc/api/courses.html#method.courses.index)
- [GET] [getSingleCourse](https://canvas.instructure.com/doc/api/courses.html#method.courses.show)
- [GET] [listModules](https://canvas.instructure.com/doc/api/modules.html#method.context_modules_api.index)
- [GET] [listModuleItems](https://canvas.instructure.com/doc/api/modules.html#method.context_module_items_api.index)
- [GET] [searchCourses](https://canvas.instructure.com/doc/api/search.html#method.search.all_courses)
Below was generated with a combination of [Canvas API Reference](https://canvas.instructure.com/doc/api/index.html) and the [ActionsGPT](https://chatgpt.com/g/g-TYEliDU6A-actionsgpt).
```yaml
openapi: 3.1.0
info:
title: Canvas API
description: API for interacting with Canvas LMS, including courses, modules, module items, and search functionalities.
version: 1.0.0
servers:
- url: https://canvas.instructure.com/api/v1
description: Canvas LMS API server
variables:
domain:
default: canvas.instructure.com
description: The domain of your Canvas instance
paths:
/courses:
get:
operationId: listYourCourses
summary: List your courses
description: Retrieves a paginated list of active courses for the current user.
parameters:
- name: enrollment_type
in: query
description: Filter by enrollment type (e.g., "teacher", "student").
schema:
type: string
- name: enrollment_role
in: query
description: Filter by role type. Requires admin permissions.
schema:
type: string
- name: enrollment_state
in: query
description: Filter by enrollment state (e.g., "active", "invited").
schema:
type: string
- name: exclude_blueprint_courses
in: query
description: Exclude Blueprint courses if true.
schema:
type: boolean
- name: include
in: query
description: Array of additional information to include (e.g., "term", "teachers").
schema:
type: array
items:
type: string
- name: per_page
in: query
description: The number of results to return per page.
schema:
type: integer
example: 10
- name: page
in: query
description: The page number to return.
schema:
type: integer
example: 1
responses:
'200':
description: A list of courses.
content:
application/json:
schema:
type: array
items:
type: object
properties:
id:
type: integer
description: The ID of the course.
name:
type: string
description: The name of the course.
account_id:
type: integer
description: The ID of the account associated with the course.
enrollment_term_id:
type: integer
description: The ID of the term associated with the course.
start_at:
type: string
format: date-time
description: The start date of the course.
end_at:
type: string
format: date-time
description: The end date of the course.
course_code:
type: string
description: The course code.
state:
type: string
description: The current state of the course (e.g., "unpublished", "available").
'400':
description: Bad request, possibly due to invalid query parameters.
'401':
description: Unauthorized, likely due to invalid authentication credentials.
/courses/{course_id}:
get:
operationId: getSingleCourse
summary: Get a single course
description: Retrieves the details of a specific course by its ID.
parameters:
- name: course_id
in: path
required: true
description: The ID of the course.
schema:
type: integer
- name: include
in: query
description: Array of additional information to include (e.g., "term", "teachers").
schema:
type: array
items:
type: string
responses:
'200':
description: A single course object.
content:
application/json:
schema:
type: object
properties:
id:
type: integer
description: The ID of the course.
name:
type: string
description: The name of the course.
account_id:
type: integer
description: The ID of the account associated with the course.
enrollment_term_id:
type: integer
description: The ID of the term associated with the course.
start_at:
type: string
format: date-time
description: The start date of the course.
end_at:
type: string
format: date-time
description: The end date of the course.
course_code:
type: string
description: The course code.
state:
type: string
description: The current state of the course (e.g., "unpublished", "available").
is_public:
type: boolean
description: Whether the course is public.
syllabus_body:
type: string
description: The syllabus content of the course.
term:
type: object
description: The term associated with the course.
properties:
id:
type: integer
name:
type: string
start_at:
type: string
format: date-time
end_at:
type: string
format: date-time
'400':
description: Bad request, possibly due to an invalid course ID or query parameters.
'401':
description: Unauthorized, likely due to invalid authentication credentials.
'404':
description: Course not found, possibly due to an invalid course ID.
/courses/{course_id}/modules:
get:
operationId: listModules
summary: List modules in a course
description: Retrieves the list of modules for a given course in Canvas.
parameters:
- name: course_id
in: path
required: true
description: The ID of the course.
schema:
type: integer
- name: include
in: query
description: Include additional information such as items in the response.
schema:
type: array
items:
type: string
example: ["items"]
- name: search_term
in: query
description: The partial title of the module to match and return.
schema:
type: string
- name: student_id
in: query
description: Return module completion information for the student with this ID.
schema:
type: integer
- name: per_page
in: query
description: The number of results to return per page.
schema:
type: integer
example: 10
- name: page
in: query
description: The page number to return.
schema:
type: integer
example: 1
responses:
'200':
description: A list of modules in the course.
content:
application/json:
schema:
type: array
items:
type: object
properties:
id:
type: integer
description: The ID of the module.
name:
type: string
description: The name of the module.
items_count:
type: integer
description: The number of items in the module.
state:
type: string
description: The state of the module (e.g., "active", "locked").
'400':
description: Bad request, possibly due to an invalid course ID or query parameters.
'401':
description: Unauthorized, likely due to invalid authentication credentials.
'404':
description: Course not found, possibly due to an invalid course ID.
/courses/{course_id}/modules/{module_id}/items:
get:
operationId: listModuleItems
summary: List items in a module
description: Retrieves the list of items within a specific module in a Canvas course.
parameters:
- name: course_id
in: path
required: true
description: The ID of the course.
schema:
type: integer
- name: module_id
in: path
required: true
description: The ID of the module.
schema:
type: integer
- name: include
in: query
description: Include additional information in the response, such as content details.
schema:
type: array
items:
type: string
example: ["content_details"]
- name: student_id
in: query
description: Return completion information for the student with this ID.
schema:
type: integer
- name: per_page
in: query
description: The number of results to return per page.
schema:
type: integer
example: 10
- name: page
in: query
description: The page number to return.
schema:
type: integer
example: 1
responses:
'200':
description: A list of items in the module.
content:
application/json:
schema:
type: array
items:
type: object
properties:
id:
type: integer
description: The ID of the module item.
title:
type: string
description: The title of the module item.
type:
type: string
description: The type of the module item (e.g., "Assignment", "File").
position:
type: integer
description: The position of the item within the module.
indent:
type: integer
description: The level of indentation of the item in the module.
completion_requirement:
type: object
description: The completion requirement for the item.
properties:
type:
type: string
min_score:
type: integer
content_id:
type: integer
description: The ID of the associated content item (e.g., assignment, file).
state:
type: string
description: The state of the item (e.g., "active", "locked").
'400':
description: Bad request, possibly due to an invalid module ID or query parameters.
'401':
description: Unauthorized, likely due to invalid authentication credentials.
'404':
description: Module or course not found, possibly due to an invalid module or course ID.
/search/all_courses:
get:
operationId: searchCourses
summary: Search for courses
description: Searches for public courses in Canvas.
parameters:
- name: search
in: query
description: The search term to filter courses.
schema:
type: string
- name: public_only
in: query
description: If true, only returns public courses.
schema:
type: boolean
- name: open_enrollment_only
in: query
description: If true, only returns courses with open enrollment.
schema:
type: boolean
- name: enrollment_type
in: query
description: Filter by enrollment type (e.g., "teacher", "student").
schema:
type: string
- name: sort
in: query
description: Sort the results by "asc" or "desc" order.
schema:
type: string
enum:
- asc
- desc
- name: per_page
in: query
description: The number of results to return per page.
schema:
type: integer
example: 10
- name: page
in: query
description: The page number to return.
schema:
type: integer
example: 1
responses:
'200':
description: A list of courses matching the search criteria.
content:
application/json:
schema:
type: array
items:
type: object
properties:
id:
type: integer
description: The ID of the course.
name:
type: string
description: The name of the course.
account_id:
type: integer
description: The ID of the account associated with the course.
enrollment_term_id:
type: integer
description: The ID of the term associated with the course.
start_at:
type: string
format: date-time
description: The start date of the course.
end_at:
type: string
format: date-time
description: The end date of the course.
course_code:
type: string
description: The course code.
state:
type: string
description: The current state of the course (e.g., "unpublished", "available").
is_public:
type: boolean
description: Whether the course is public.
term:
type: object
description: The term associated with the course.
properties:
id:
type: integer
name:
type: string
start_at:
type: string
format: date-time
end_at:
type: string
format: date-time
'400':
description: Bad request, possibly due to invalid query parameters.
'401':
description: Unauthorized, likely due to invalid authentication credentials.
'404':
description: No courses found matching the criteria.
```
### Sample Conversation Starters
- Help me take a practice exam.
- Give an overview of one of my courses.
- List all of my courses.
### GPT Capabilities
- [On] Web Browsing
- [On] DALL·E Image Generation
- [On] Code Interpreter & Data Analysis
## Other Use Cases for Consideration
Below is a non-exhaustive list of additional use cases that could be explored using the Canvas API. The basic outline for each is provided, but the GPT Instructions and specific API calls referenced are intentionally left to you as the user to decide what works best for your needs.
### Classroom Analytics and Reports
**Use Case:** Empowers teachers with comprehensive analytics and performance reports on student engagement, grades, and participation. By leveraging this data, teachers can make informed decisions to tailor their course delivery, identify at-risk students, and enhance overall classroom effectiveness.
**API Resources:**
- [**Analytics**](https://canvas.instructure.com/doc/api/analytics.html) and [**Quiz Statistics**](https://canvas.instructure.com/doc/api/quiz_statistics.html): Retrieve detailed data on student participation, grades, and course-level statistics.
- [**Quiz Reports**](https://canvas.instructure.com/doc/api/quiz_reports.html): Generate and view various reports to analyze overall class performance and track progress over time.
### Review and Improvement Guidance for Graded Assignments
**Use Case:** Provide students with a tool to review their graded assignments, analyze their performance, and receive targeted guidance on how to improve in areas where they have knowledge gaps. The tool can highlight specific questions or sections where the student struggled and suggest additional resources or practice materials to help them improve.
**API Resources:**
- [**Submissions**](https://canvas.instructure.com/doc/api/submissions.html) and [**Quiz Submissions**](https://canvas.instructure.com/doc/api/quiz_submissions.html): Retrieve the students submissions and associated grades.
- [**Assignments**](https://canvas.instructure.com/doc/api/assignments.html): Retrieve detailed information about the assignment, including rubrics and grading criteria.
- [**Rubric Assessments**](https://canvas.instructure.com/doc/api/rubrics.html): Access detailed feedback and rubric assessments
- [**Modules**](https://canvas.instructure.com/doc/api/modules.html): Suggest additional learning modules that target the students weak areas using the List modules API.
- [**Quizzes**](https://canvas.instructure.com/doc/api/quizzes.html): Recommend practice quizzes to help the student improve on specific knowledge gaps
# Congratulations!
Youve successfully created a Custom GPT with a working Custom Action using Canvas LMS. You should be able to have a conversation that looks similar to the screenshot below. Great job and keep going!
![canvas_lms_sample_conversation.png](../../../images/canvas_lms_sample_conversation.png)

View File

@ -1,696 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# GPT Action Library: Canvas LMS"
]
},
{
"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 Buliding 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 [Canvas](https://www.instructure.com/canvas), a widely used LMS tool for course material, grading and general education purposes. "
]
},
{
"cell_type": "markdown",
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"source": [
"### Value + Example Business Use Cases"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Value**: Users can now leverage ChatGPT's natural language capability to connect directly to Canvas\n",
"\n",
"**Example Use Cases**:\n",
"- Query content from LMS \n",
"- Build quizzes\n",
"- Create new modules\n",
"- Understand topics from assigned courses"
]
},
{
"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://canvas.instructure.com/login/canvas \n",
"- Application API Documentation: https://canvas.instructure.com/doc/api/\n",
" "
]
},
{
"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 the access and permissions in Canvas to create an approved integration with an Access Token for testing\n",
"- For OAuth connection see here : https://canvas.instructure.com/doc/api/file.oauth.html\n",
"\n",
"\n",
"![gptactions_canvaslms_approvedintegrations.png](../../../images/gptactions_canvaslms_approvedintegrations.png)\n"
]
},
{
"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": [
"**Context** : You are a helpful friendly university level course helper designed to search across canvas courses to help students and educators, this GPT is intended to help students and teachers understand course material, take quiz's and tests from information stored in canvas. \n",
"\n",
"\n",
"**Instructions**\n",
"When asked to perform a task, use the available actions via the canvas.infrastructure.com API\n",
"\n",
"\n",
"You should be professional and verbose with answers, provide clear pedagogical experience for users. \n",
"\n",
"\n",
"Offer assistance with tasks around summarizing course material, understanding module and quiz information. \n",
"\n",
"\n",
"Ask for clarification when needed to ensure accuracy and completeness in fulfilling user requests. It should also respect user privacy and handle all data securely.\n",
"\n",
"\n",
"If a user uploads a file, help the user analyze the file before callin the canvas API.\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: Canvas LMS API\n",
" description: >\n",
" This is the API of the Canvas LMS, providing access to various resources such as accounts, courses, users,\n",
" assignments, quizzes, files, and more.\n",
" version: 1.0.0\n",
"servers:\n",
" - url: https://canvas.instructure.com\n",
" description: Canvas LMS Production Server\n",
"paths:\n",
" /api/v1/accounts:\n",
" get:\n",
" summary: List accounts\n",
" operationId: listAccounts\n",
" responses:\n",
" \"200\":\n",
" description: A paginated list of accounts\n",
" content:\n",
" application/json:\n",
" schema:\n",
" type: array\n",
" items:\n",
" $ref: \"#/components/schemas/Account\"\n",
" /api/v1/accounts/{account_id}:\n",
" get:\n",
" summary: Get a single account\n",
" operationId: getAccount\n",
" parameters:\n",
" - name: account_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" responses:\n",
" \"200\":\n",
" description: Account details\n",
" content:\n",
" application/json:\n",
" schema:\n",
" $ref: \"#/components/schemas/Account\"\n",
" /api/v1/courses:\n",
" get:\n",
" summary: List courses\n",
" operationId: listCourses\n",
" responses:\n",
" \"200\":\n",
" description: A paginated list of courses\n",
" content:\n",
" application/json:\n",
" schema:\n",
" type: array\n",
" items:\n",
" $ref: \"#/components/schemas/Course\"\n",
" /api/v1/courses/{course_id}:\n",
" get:\n",
" summary: Get a single course\n",
" operationId: getCourse\n",
" parameters:\n",
" - name: course_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" responses:\n",
" \"200\":\n",
" description: Course details\n",
" content:\n",
" application/json:\n",
" schema:\n",
" $ref: \"#/components/schemas/Course\"\n",
" /api/v1/courses/{course_id}/assignments:\n",
" get:\n",
" summary: List assignments\n",
" operationId: listAssignments\n",
" parameters:\n",
" - name: course_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" responses:\n",
" \"200\":\n",
" description: A paginated list of assignments\n",
" content:\n",
" application/json:\n",
" schema:\n",
" type: array\n",
" items:\n",
" $ref: \"#/components/schemas/Assignment\"\n",
" /api/v1/courses/{course_id}/assignments/{assignment_id}:\n",
" get:\n",
" summary: Get a single assignment\n",
" operationId: getAssignment\n",
" parameters:\n",
" - name: course_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" - name: assignment_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" responses:\n",
" \"200\":\n",
" description: Assignment details\n",
" content:\n",
" application/json:\n",
" schema:\n",
" $ref: \"#/components/schemas/Assignment\"\n",
" /api/v1/courses/{course_id}/quizzes:\n",
" get:\n",
" summary: List quizzes\n",
" operationId: listQuizzes\n",
" parameters:\n",
" - name: course_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" responses:\n",
" \"200\":\n",
" description: A paginated list of quizzes\n",
" content:\n",
" application/json:\n",
" schema:\n",
" type: array\n",
" items:\n",
" $ref: \"#/components/schemas/Quiz\"\n",
" /api/v1/courses/{course_id}/quizzes/{quiz_id}:\n",
" get:\n",
" summary: Get a single quiz\n",
" operationId: getQuiz\n",
" parameters:\n",
" - name: course_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" - name: quiz_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" responses:\n",
" \"200\":\n",
" description: Quiz details\n",
" content:\n",
" application/json:\n",
" schema:\n",
" $ref: \"#/components/schemas/Quiz\"\n",
" /api/v1/courses/{course_id}/students/{student_id}/grades:\n",
" get:\n",
" summary: List grades for a student\n",
" operationId: listGrades\n",
" parameters:\n",
" - name: course_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" - name: student_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" responses:\n",
" '200':\n",
" description: A list of grades for the student\n",
" content:\n",
" application/json:\n",
" schema:\n",
" type: array\n",
" items:\n",
" $ref: '#/components/schemas/Grade'\n",
" /api/v1/courses/{course_id}/students/{student_id}/grades/{grade_id}:\n",
" get:\n",
" summary: Get a single grade\n",
" operationId: getGrade\n",
" parameters:\n",
" - name: course_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" - name: student_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" - name: grade_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" responses:\n",
" '200':\n",
" description: Grade details\n",
" content:\n",
" application/json:\n",
" schema:\n",
" $ref: '#/components/schemas/Grade'\n",
" /api/v1/courses/{course_id}/syllabus:\n",
" get:\n",
" summary: Get course syllabus\n",
" operationId: getSyllabus\n",
" parameters:\n",
" - name: course_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" responses:\n",
" '200':\n",
" description: Syllabus details\n",
" content:\n",
" application/json:\n",
" schema:\n",
" $ref: '#/components/schemas/Syllabus'\n",
" /api/v1/courses/{course_id}/modules:\n",
" get:\n",
" summary: List modules\n",
" operationId: listModules\n",
" parameters:\n",
" - name: course_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" responses:\n",
" '200':\n",
" description: A list of modules in the course\n",
" content:\n",
" application/json:\n",
" schema:\n",
" type: array\n",
" items:\n",
" $ref: '#/components/schemas/Module'\n",
" /api/v1/courses/{course_id}/modules/{module_id}:\n",
" get:\n",
" summary: Get a single module\n",
" operationId: getModule\n",
" parameters:\n",
" - name: course_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" - name: module_id\n",
" in: path\n",
" required: true\n",
" schema:\n",
" type: integer\n",
" responses:\n",
" '200':\n",
" description: Module details\n",
" content:\n",
" application/json:\n",
" schema:\n",
" $ref: '#/components/schemas/Module'\n",
"components:\n",
" schemas:\n",
" Account:\n",
" type: object\n",
" properties:\n",
" id:\n",
" type: integer\n",
" name:\n",
" type: string\n",
" workflow_state:\n",
" type: string\n",
" Course:\n",
" type: object\n",
" properties:\n",
" id:\n",
" type: integer\n",
" name:\n",
" type: string\n",
" account_id:\n",
" type: integer\n",
" start_at:\n",
" type: string\n",
" format: date-time\n",
" end_at:\n",
" type: string\n",
" format: date-time\n",
" Assignment:\n",
" type: object\n",
" properties:\n",
" id:\n",
" type: integer\n",
" name:\n",
" type: string\n",
" description:\n",
" type: string\n",
" due_at:\n",
" type: string\n",
" format: date-time\n",
" points_possible:\n",
" type: number\n",
" Quiz:\n",
" type: object\n",
" properties:\n",
" id:\n",
" type: integer\n",
" title:\n",
" type: string\n",
" description:\n",
" type: string\n",
" due_at:\n",
" type: string\n",
" format: date-time\n",
" points_possible:\n",
" type: number\n",
" Grade:\n",
" type: object\n",
" properties:\n",
" id:\n",
" type: integer\n",
" student_id:\n",
" type: integer\n",
" course_id:\n",
" type: integer\n",
" assignment_id:\n",
" type: integer\n",
" score:\n",
" type: number\n",
" grade:\n",
" type: string\n",
" Syllabus:\n",
" type: object\n",
" properties:\n",
" id:\n",
" type: integer\n",
" name:\n",
" type: string\n",
" account_id:\n",
" type: integer\n",
" start_at:\n",
" type: string\n",
" format: date-time\n",
" end_at:\n",
" type: string\n",
" format: date-time\n",
" syllabus_body:\n",
" type: string\n",
" syllabus_url:\n",
" type: string\n",
" Module:\n",
" type: object\n",
" properties:\n",
" id:\n",
" type: integer\n",
" name:\n",
" type: string\n",
" position:\n",
" type: integer\n",
" unlock_at:\n",
" type: string\n",
" format: date-time\n",
" require_sequential_progress:\n",
" type: boolean\n",
" state:\n",
" type: string\n",
" securitySchemes:\n",
" bearerAuth:\n",
" type: http\n",
" scheme: bearer\n",
" bearerFormat: JWT\n",
"security:\n",
" - bearerAuth: []"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Note : this schema above does not contain all possible API endpoints, be sure to edit the schema to produce the appropriate actions from canvas [API documentation](https://canvas.instructure.com/doc/api/)**"
]
},
{
"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, please take the following steps in the application. Our sample integration below is utilizing a secret key, which is an easier method for testing. In production, it is more common to establish an OAuth connection to ensure permissions are respected from ChatGPT to Canvas, ensuring users the appropriate access. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. Canvas accounts : The first step is to ensure the canvas environment has users assigned to the appropriate role (student / teacher) with any access to appropriate courses\n",
"2. For testing purposes or service level account access create an approved integration access token as seen below\n",
"- Under Account -> Settings -> Approved Integrations\n",
"\n",
"<br> ![gptactions_canvaslms_settings.png](../../../images/gptactions_canvaslms_settings.png)\n",
"\n",
"- Create new Access Token\n",
"\n",
"<br> ![gptactions_canvaslms_integrationslist.png](../../../images/gptactions_canvaslms_integrationslist.png)\n",
"\n",
"- Provide purpose and expiration\n",
"\n",
"<br> ![gptactions_canvaslms_tokencreate.png](../../../images/gptactions_canvaslms_tokencreate.png)\n",
"\n",
"- Copy the new Token to use in the GPT Action (the token will not be accessible once you leave the page - ensure proper token management access is maintained to prevent unauthorzied access from another application.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### In ChatGPT"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In ChatGPT, click on \"Authentication\" and choose **\"API Key\"**. Enter in the information below. API Key provides general access to the Canvas environment based on the users permissions that created the API key, to follow permission models in Canvas use the OAuth method described below."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- **API Key**: Use the token from above \n",
"- **Auth Type**: Bearer\n",
"\n",
"<br> ![gptactions_canvaslms_auth.png](../../../images/gptactions_canvaslms_auth.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**OAuth Connection**\n",
"\n",
"If you want to implement OAuth, follow the guide here : https://canvas.instructure.com/doc/api/file.oauth.html - specific instructions can vary depending on the Canvas implementation.\n",
"\n",
"Parameters for GPT Configuration\n",
"- Client ID - obtained from site owner\n",
"- Client Secret - obtained from site owner \n",
"- Authorization URL - : https://< canvas-install-url >/login/oauth2/auth?client_id=XXX&response_type=code&redirect_uri=https://example.com/oauth_complete&state=YYY&scope=< value_1 >%20< value_2 >%20< value_n >\n",
"- Token URL : https://< canvas-install-url> /login/oauth2/token "
]
},
{
"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 test the Action."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- You will see a list of available actions from the API schema for Canvas, you can test the endpoints from the GPT builder to ensure Canvas can be reached. Once you verified connection make sure to save the GPT and share it witht the appropriate user base.\n",
"- Note: if you are using OAuth, you will need to set up the callback URL from ChatGPT in the Canvas app"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### FAQ & Troubleshooting"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- *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"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Are there integrations that youd like us to prioritize? Are there errors in our integrations? File a PR or issue in our github, and well take a look.*\n"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

View File

@ -1394,11 +1394,12 @@
- gpt-actions-library
- chatgpt
- title: GPT Actions library - Canvas LMS
path: examples/chatgpt/gpt_actions_library/gpt_action_canvaslms.ipynb
date: 2024-07-17
- title: GPT Actions library - Canvas Learning Management System
path: examples/chatgpt/gpt_actions_library/gpt_action_canvas.md
date: 2024-09-17
authors:
- keelan-openai
- joecasson-openai
tags:
- gpt-actions-library
- chatgpt