Using Bard in Sheets

128 views
Skip to first unread message

Ji Davis

unread,
Jun 30, 2023, 8:44:21 AM6/30/23
to Google Apps Script Community
I've been trying to generate a bard response in column I using a prompt in column A. In column A i have an instagram url and I want the prompt for Bard to provide me the website url of that instagram account in column I. What scripts code should I use?
I currently have this from Bard but it isn't working
function onEdit(e) {
const sheet = e.range.getSheet();
const cellValue = sheet.getRange(e.range.rowStart, e.range.columnStart).getValue();
const bardPrompt = sheet.getRange("A" + e.range.rowStart).getValue();
const bardResponse = Bard.query(bardPrompt);
sheet.getRange("I" + (e.range.rowStart + 1)).setValue(bardResponse);
}

Many thanks!

Ji Davis

unread,
Jun 30, 2023, 8:47:55 AM6/30/23
to Google Apps Script Community
Apologies, this is the correct code I have used (but it doesn't work)

function onEdit(e) { if (e) { const sheet = e.range.getSheet(); const cellValue = sheet.getRange(e.range.rowStart, e.range.columnStart).getValue(); const bardPrompt = "Provide only the website URL for " + sheet.getRange("A" + e.range.rowStart).getValue(); const bardResponse = Bard.query(bardPrompt); sheet.getRange("I" + (e.range.rowStart + 1)).setValue(bardResponse); } }
Reply all
Reply to author
Forward
0 new messages