While working with new AI Prompt Workflow Concepts
I wanted to be able to update my ChatBots from a central source. I use JSON for many AI workflows.
Github is a very cost effective way to build a testing platform and test your prompts. It’s a virtual prompt library all your Apps Script based AI interactions can access.
You will need to make a personal access token for this to work. Here are the instructions: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
In Apps Script, if you get an error, it is likely permissions. Make sure your Apps Script JSON properties file is visible.
Google Apps Script Logger or Console will tell you if you need to add a line to that file.
Once you get this working, move the URL and Token reference to script properties.
function getJsonFromGitHub() {
// Raw GitHub file URL. You need to update this.
var url = 'https://raw.githubusercontent.com/*_*/sampleJ.json';
// GitHub Personal Access Token for Authorization
var token = 'github_INSERT YOUR TOKEN'; // Replace with your actual GitHub token
// Set up the request headers with the token for authentication
var headers = {
"Authorization": "Bearer " + token
};
// Fetch the content of the JSON file from GitHub
var response = UrlFetchApp.fetch(url, {
"method": "get",
"headers": headers
});
// Get the content of the file as a string
var fileContent = response.getContentText();
// Parse the JSON string into an object
var jsonData = JSON.parse(fileContent);
// Log the JSON data to the Apps Script log
Logger.log(jsonData);
//This is my AI function. You will need to write one
callChatAIJson(jsonData);
}
If you need an example JSON, here you go.
{
"meta": {
"purpose": "This is an example for crafting AI responses. Do not include this exact text in the response.",
"instructions": "Use the provided structure, tone, and style as guidance to craft a new response tailored to the specific input."
},
"example": {
"comments": [
"Arlynn is excelling in class, consistently leading discussions with thoughtful questions and insightful contributions. She has completed outstanding work on assessments, including an exceptional essay on *Beloved*. Her strengths include leadership in class discussions, insightful contributions, and producing high-quality work on assessments. Keep up the excellent work, Arlynn!"
],
"speaking_style": "Traditional Southern Aristocrat",
"aesthetic": "Refined and Diplomatic",
"word_count_range": {
"min": 75,
"max": 100
},
"paragraph_count_range": {
"min": 1,
"max": 1
}
}
}