"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."
"Once you've created a Custom GPT, copy the text below in the Actions panel. Update the servers url to match your Snowflake Account Name url plus `/api/v2` as described [here](https://docs.snowflake.com/en/user-guide/organizations-connect#standard-account-urls). Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail."
]
]
},
},
{
{
@ -161,7 +161,7 @@
" version: 1.0.0\n",
" version: 1.0.0\n",
" description: API for executing statements in Snowflake with specific warehouse and role settings.\n",
" description: API for executing statements in Snowflake with specific warehouse and role settings.\n",
"servers:\n",
"servers:\n",
" - url: 'https://<your server ID>.<your cloud region>.<your cloud provider>.snowflakecomputing.com/api/v2'\n",
"* Review the Snowflake OAuth Overview: [https://docs.snowflake.com/en/user-guide/oauth-snowflake-overview](https://docs.snowflake.com/en/user-guide/oauth-snowflake-overview)\n",
"* Review the Snowflake OAuth Overview: [https://docs.snowflake.com/en/user-guide/oauth-snowflake-overview](https://docs.snowflake.com/en/user-guide/oauth-snowflake-overview)\n",
"* Go to the Snowflake Worksheets\n",
"* Create new OAuth credentials through a [Security Integration](https://docs.snowflake.com/en/sql-reference/sql/create-security-integration-oauth-snowflake) - you will need a new one for each OAuth app/custom GPT since Snowflake Redirect URIs are 1-1 mapped to Security Integrations"
"* Create new OAuth credentials through a [Security Integration](https://docs.snowflake.com/en/sql-reference/sql/create-security-integration-oauth-snowflake) - you will need a new one for each OAuth app/custom GPT since Snowflake Redirect URIs are 1-1 mapped to Security Integrations\n"
]
]
},
},
{
{
@ -267,7 +304,8 @@
" OAUTH_CLIENT_TYPE = 'CONFIDENTIAL'\n",
" OAUTH_CLIENT_TYPE = 'CONFIDENTIAL'\n",
" OAUTH_REDIRECT_URI = 'https://oauth.pstmn.io/v1/callback' --- // this is a temporary value while testing your integration. You will replace this with the value your GPT provides\n",
" OAUTH_REDIRECT_URI = 'https://oauth.pstmn.io/v1/callback' --- // this is a temporary value while testing your integration. You will replace this with the value your GPT provides\n",
" OAUTH_ISSUE_REFRESH_TOKENS = TRUE\n",
" OAUTH_ISSUE_REFRESH_TOKENS = TRUE\n",
" OAUTH_REFRESH_TOKEN_VALIDITY = 7776000;"
" OAUTH_REFRESH_TOKEN_VALIDITY = 7776000;\n",
" NETWORK_POLICY = chatgpt_network_policy --- // this line should only be included if you followed step 1 above"
"You’ll find the Client Secret in OAUTH_CLIENT_SECRET.\n",
"You’ll find the Client Secret in OAUTH_CLIENT_SECRET. Do not include the double quotes when copying the value.\n",
"\n",
"\n",
"You’re now set to test your action in Postman. Once you get a successful API response there, you can proceed with your GPT Action."
"Now is a good time to [test your Snowflake integration in Postman](https://community.snowflake.com/s/article/How-to-configure-postman-for-testing-SQL-API-with-OAuth). If you copnfigured a network policy for your security integration, ensure that it includes the IP of the machine you're using to test."
]
]
},
},
{
{
@ -332,12 +389,15 @@
"source": [
"source": [
"In ChatGPT, click on \"Authentication\" and choose \"OAuth\". Enter in the information below.\n",
"In ChatGPT, click on \"Authentication\" and choose \"OAuth\". Enter in the information below.\n",
"\n",
"\n",
"* Client ID: use Client ID from steps above\n",
"| Form Field | Value |\n",
"* Client Secret: use Client Secret from steps above\n",
"| -------- | -------- |\n",
"* Authorization URL: use Authorization Endpoint from steps above\n",
"| Authentication Type | OAuth |\n",
"* Token URL: use Token Endpoint from steps above\n",
"| Client ID | OAUTH_CLIENT_ID from SHOW_OAUTH_CLIENT_SECRETS |\n",
"* Scope: <empty>*\n",
"| Authorization URL | OAUTH_AUTHORIZATION_ENDPOINT from DESCRIBE SECURITY INTEGRATION |\n",
"* Token: Default (POST)\n",
"| Token URL | OAUTH_TOKEN_ENDPOINT from DESCRIBE SECURITY INTEGRATION |\n",
"*Snowflake scopes pass the role, but you’ll notice the action itself also specifies the role as a parameter in runQuery, so the Scope is unnecessary. You may elect to pass roles in the scope instead of the action parameters if it makes more sense for your GPT."
"*Snowflake scopes pass the role, but you’ll notice the action itself also specifies the role as a parameter in runQuery, so the Scope is unnecessary. You may elect to pass roles in the scope instead of the action parameters if it makes more sense for your GPT."
]
]
@ -384,7 +444,7 @@
"cell_type": "markdown",
"cell_type": "markdown",
"metadata": {},
"metadata": {},
"source": [
"source": [
"\n",
"* The callback url can change if you update the YAML, double check it is correct when making changes.\n",
"* _Callback URL Error:_ If you get a callback URL error in ChatGPT, pay close attention to the Post-Action Steps above. You need to add the callback URL directly into your Security Integration for the action to authenticate correctly\n",
"* _Callback URL Error:_ If you get a callback URL error in ChatGPT, pay close attention to the Post-Action Steps above. You need to add the callback URL directly into your Security Integration for the action to authenticate correctly\n",
"* _Schema calls the wrong warehouse or database:_ If ChatGPT calls the wrong warehouse or database, consider updating your instructions to make it more explicit either (a) which warehouse / database should be called or (b) to require the user provide those exact details before it runs the query\n"
"* _Schema calls the wrong warehouse or database:_ If ChatGPT calls the wrong warehouse or database, consider updating your instructions to make it more explicit either (a) which warehouse / database should be called or (b) to require the user provide those exact details before it runs the query\n"