outlook gpt action upload (#1281)

This commit is contained in:
rupert-openai 2024-07-16 21:03:08 +01:00 committed by GitHub
parent a254b498a4
commit 9c0737c793
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 576 additions and 1 deletions

View File

@ -107,3 +107,9 @@ charuj:
name: "Charu Jaiswal"
website: "https://www.linkedin.com/in/charu-j-8a866471"
avatar: "https://avatars.githubusercontent.com/u/18404643?v=4"
rupert-openai:
name: "Rupert Truman"
website: "https://www.linkedin.com/in/rupert-truman/"
avatar: "https://avatars.githubusercontent.com/u/171234447"

View File

@ -0,0 +1,560 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# GPT Action Library: Outlook"
]
},
{
"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-library)\n",
"- [Example of Buliding a GPT Action from Scratch](https://platform.openai.com/docs/getting-started)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This particular GPT Action provides an overview of how to connect to Outlook, Microsoft's web service for emailing and calendar events. This action assumes a users context and allows them to send and retrieve emails and calendar events from Outlook."
]
},
{
"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://portal.azure.com/\n",
"- Application API Documentation: https://learn.microsoft.com/en-us/graph/api/overview?view=graph-rest-1.0"
]
},
{
"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 to [Set up an App Registration in Azure](https://portal.azure.com/?feature.tokencaching=true&feature.internalgraphapiversion=true#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade)"
]
},
{
"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/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 specialized GPT designed to manage emails and calendar events through API connections to Microsoft Outlook. This GPT can create, read, send, and alter emails and calendar events based on user instructions. It ensures efficient handling of communication and scheduling needs by leveraging Microsoft Graph API for seamless integration with Outlook services.\n",
"\n",
"**Instructions**:\n",
"- When asked to perform a task, use the available actions via the microsoft.graph.com API.\n",
"- You should behave professionally and provide clear, concise responses.\n",
"- Offer assistance with tasks such as drafting emails, scheduling meetings, organising calendar events, and retrieving email or event details.\n",
"- Ask for clarification when needed to ensure accuracy and completeness in fulfilling user requests.\n",
"- Always conclude an email by signing off with logged in user's name which can be retrieved via the User.Read endpoint\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/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: Microsoft Graph API Integration\n",
" version: 1.0.0\n",
"servers:\n",
" - url: https://graph.microsoft.com/v1.0\n",
"components:\n",
" securitySchemes:\n",
" OAuth2:\n",
" type: oauth2\n",
" flows:\n",
" clientCredentials:\n",
" tokenUrl: https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token\n",
" scopes:\n",
" https://graph.microsoft.com/User.Read: Access current user profile\n",
" https://graph.microsoft.com/Mail.Read: Read user mail\n",
" https://graph.microsoft.com/Mail.Send: Send mail\n",
" https://graph.microsoft.com/Calendars.ReadWrite: Read and write user calendars\n",
" schemas:\n",
" UserProfile:\n",
" type: object\n",
" properties:\n",
" id:\n",
" type: string\n",
" displayName:\n",
" type: string\n",
" mail:\n",
" type: string\n",
" UserMessage:\n",
" type: object\n",
" properties:\n",
" id:\n",
" type: string\n",
" subject:\n",
" type: string\n",
" bodyPreview:\n",
" type: string\n",
" CalendarEvent:\n",
" type: object\n",
" properties:\n",
" id:\n",
" type: string\n",
" subject:\n",
" type: string\n",
" start:\n",
" type: object\n",
" properties:\n",
" dateTime:\n",
" type: string\n",
" timeZone:\n",
" type: string\n",
" end:\n",
" type: object\n",
" properties:\n",
" dateTime:\n",
" type: string\n",
" timeZone:\n",
" type: string\n",
" NewEvent:\n",
" type: object\n",
" properties:\n",
" subject:\n",
" type: string\n",
" start:\n",
" type: object\n",
" properties:\n",
" dateTime:\n",
" type: string\n",
" timeZone:\n",
" type: string\n",
" end:\n",
" type: object\n",
" properties:\n",
" dateTime:\n",
" type: string\n",
" timeZone:\n",
" type: string\n",
" attendees:\n",
" type: array\n",
" items:\n",
" type: object\n",
" properties:\n",
" emailAddress:\n",
" type: object\n",
" properties:\n",
" address:\n",
" type: string\n",
" name:\n",
" type: string\n",
" SendMailRequest:\n",
" type: object\n",
" properties:\n",
" message:\n",
" type: object\n",
" properties:\n",
" subject:\n",
" type: string\n",
" body:\n",
" type: object\n",
" properties:\n",
" contentType:\n",
" type: string\n",
" content:\n",
" type: string\n",
" toRecipients:\n",
" type: array\n",
" items:\n",
" type: object\n",
" properties:\n",
" emailAddress:\n",
" type: object\n",
" properties:\n",
" address:\n",
" type: string\n",
"security:\n",
" - OAuth2: []\n",
"paths:\n",
" /me:\n",
" get:\n",
" operationId: getUserProfile\n",
" summary: Get the authenticated user's profile\n",
" security:\n",
" - OAuth2: []\n",
" responses:\n",
" '200':\n",
" description: A user profile\n",
" content:\n",
" application/json:\n",
" schema:\n",
" $ref: '#/components/schemas/UserProfile'\n",
" /me/messages:\n",
" get:\n",
" operationId: getUserMessages\n",
" summary: Get the authenticated user's messages\n",
" security:\n",
" - OAuth2: []\n",
" parameters:\n",
" - name: $top\n",
" in: query\n",
" required: false\n",
" schema:\n",
" type: integer\n",
" default: 10\n",
" description: Number of messages to return\n",
" - name: $filter\n",
" in: query\n",
" required: false\n",
" schema:\n",
" type: string\n",
" description: OData filter query to narrow results\n",
" - name: $orderby\n",
" in: query\n",
" required: false\n",
" schema:\n",
" type: string\n",
" description: OData order by query to sort results\n",
" responses:\n",
" '200':\n",
" description: A list of user messages\n",
" content:\n",
" application/json:\n",
" schema:\n",
" type: array\n",
" items:\n",
" $ref: '#/components/schemas/UserMessage'\n",
" /me/sendMail:\n",
" post:\n",
" operationId: sendUserMail\n",
" summary: Send an email as the authenticated user\n",
" security:\n",
" - OAuth2: []\n",
" requestBody:\n",
" required: true\n",
" content:\n",
" application/json:\n",
" schema:\n",
" $ref: '#/components/schemas/SendMailRequest'\n",
" responses:\n",
" '202':\n",
" description: Accepted\n",
" /me/events:\n",
" get:\n",
" operationId: getUserCalendarEvents\n",
" summary: Get the authenticated user's calendar events\n",
" security:\n",
" - OAuth2: []\n",
" responses:\n",
" '200':\n",
" description: A list of calendar events\n",
" content:\n",
" application/json:\n",
" schema:\n",
" type: array\n",
" items:\n",
" $ref: '#/components/schemas/CalendarEvent'\n",
" post:\n",
" operationId: createUserCalendarEvent\n",
" summary: Create a new calendar event for the authenticated user\n",
" security:\n",
" - OAuth2: []\n",
" requestBody:\n",
" required: true\n",
" content:\n",
" application/json:\n",
" schema:\n",
" $ref: '#/components/schemas/NewEvent'\n",
" responses:\n",
" '201':\n",
" description: Created\n",
" content:\n",
" application/json:\n",
" schema:\n",
" $ref: '#/components/schemas/CalendarEvent'\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Authentication Instructions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Below are instructions on setting up authentication with Outlook. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Azure Steps"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. <b>App Registration</b>: The first step is to register a new App registration in the [Azure Portal](portal.azure.com) which will be used to integrate OAuth between our application and Azure Active Directory/Entra ID. Simply provide the application with a relevant name, leaving the Redirect URI blank for now as we will return to this, and save."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![gptactions_outlook_registerapplication.png](../../../images/gptactions_outlook_registerapplication.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"2. <b>Certificate & Secrets</b>: We next need to generate a client secret to provide secure communication between the GPT and Azure. Within the App registration, navigate to <b>Certificate & secrets</b> in the sidebar"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![gptactions_outlook_secrets.png](../../../images/gptactions_outlook_secrets.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Click New client secret and create a new client secret with desired name and expiry date. Clicking save will provide us a Secret to use in our GPT creation. Make sure to save the **Value** field as itll only be visible at creation, and we will need it later!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![gptactions_outlook_secretvalue.png](../../../images/gptactions_outlook_secretvalue.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"3. <b>API Permissions</b>: The next step is to provide the integration with the scope it needs to perform our specific required actions. \n",
"Within the App registration, navigate to <b>Manage > API permissions</b> in the sidebar. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![gptactions_outlook_permissions.png](../../../images/gptactions_outlook_permissions.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Click <b>Add a permission</b> and <b>Microsoft graph > Delegated Permissions</b> as options in the opened side menu. Use the search bar to add the following permissions:\n",
"- Calendars.ReadWrite\n",
"- Mail.Read\n",
"- Mail.Send\n",
"- User.Read\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![gptactions_outlook_permissionadd.png](../../../images/gptactions_outlook_permissionadd.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**: The value listed on the Azure Registered Apps Overview page under **Application (client) ID**\n",
"- **Client Secret**: the secret **Value** saved from step 2 of **Azure Steps**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For the following two inputs, replace <Tenant_ID> with the value listed on the Registered Apps Overview page under **Directory (tenant) ID**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- **Authorization URL**: https://login.microsoftonline.com/<Tenant_ID>/oauth2/v2.0/authorize\n",
"- **Token URL**: https://login.microsoftonline.com/<Tenant_ID>/oauth2/v2.0/token\n",
"- **Scope**: https://graph.microsoft.com/User.Read https://graph.microsoft.com/Mail.Send https://graph.microsoft.com/Mail.Read https://graph.microsoft.com/Calendars.ReadWrite \n",
"- **Token Exchange Method**: Default (POST Request)"
]
},
{
"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"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![gptactions_outlook_callback.png](../../../images/gptactions_outlook_callback.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- In the Azure app, navigate to the **Manage > Authentication** tab, click **Add a platform**, select **Web** and add your callback URL under **Redirect URI**\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![gptactions_outlook_redirectconfig.png](../../../images/gptactions_outlook_redirectconfig.png)\n",
"![gptactions_outlook_redirectinput.png](../../../images/gptactions_outlook_redirectinput.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### FAQ & Troubleshooting"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- **Callback URL Error**: If you get a callback URL error in ChatGPT, double check the Callback URL value as it can occasionally change depending on any alterations made to the authentication\n"
]
},
{
"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: 503 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

View File

@ -1352,3 +1352,12 @@
- completions
- vision
- ocr
- title: GPT Actions library - Outlook
path: examples/chatgpt/gpt_actions_library/gpt_action_outlook.ipynb
date: 2024-07-15
authors:
- rupert-openai
tags:
- gpt-actions-library
- chatgpt