Copilotでもやってみた
ChatGPTに聞きながら、仕組みを作ってみたのときは、ChatGPTを使った。その後、Geminiでもやってみようとやってみた。そして今度は、Copilotではどうかと思いまして。
Copilotに同じ質問をした
公平にCopilotにChatGPTに入力したのと同じ質問、プロンプトを入力してみた。
全く同じものをコピペした。
当然だが、またまた回答が違う
またまた回答が違った。当たり前だけど。
Copilotでは、先にcode.gsが出てきたよ。
function doGet() {
return HtmlService.createHtmlOutputFromFile('index');
}function sendEmails(subject, body, label) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sending');
var data = sheet.getDataRange().getValues();
var headers = data[0];for (var i = 1; i < data.length; i++) {
var row = data[i];
var email = row[headers.indexOf('メールアドレス')];
var customSubject = replaceVariables(subject, row, headers);
var customBody = replaceVariables(body, row, headers);MailApp.sendEmail(email, customSubject, customBody);
// Add label
GmailApp.getMessagesForThreads(GmailApp.search('subject:' + customSubject))
.forEach(function(thread) {
thread.getMessages().forEach(function(message) {
message.addLabel(GmailApp.createLabel(label));
});
});
}
}function replaceVariables(text, row, headers) {
var replacements = {
'$氏名': row[headers.indexOf('氏名')],
'$役職': row[headers.indexOf('役職')],
'$会社名': row[headers.indexOf('会社名')],
'$部署': row[headers.indexOf('部署')],
'$コメント': row[headers.indexOf('コメント')]
};
for (var key in replacements) {
text = text.replace(new RegExp(key, 'g'), replacements[key]);
}return text;
}
index.htmlはこちら。
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
textarea {
width: 100%;
height: 150px;
}
input[type=text] {
width: 100%;
margin-bottom: 10px;
}
input[type=button] {
margin-top: 10px;
}
</style>
</head>
<body>
<h1>メール送信システム</h1>
<form id="emailForm">
<label for="subject">メールタイトル</label><br>
<input type="text" id="subject" name="subject"><br>
<label for="body">メール本文</label><br>
<textarea id="body" name="body"></textarea><br>
<label for="label">ラベル</label><br>
<input type="text" id="label" name="label"><br>
<input type="button" value="送信" onclick="confirmSend()">
<input type="button" value="キャンセル" onclick="confirmCancel()">
</form>
<script>
function confirmSend() {
var subject = document.getElementById('subject').value;
var body = document.getElementById('body').value;if (!subject) {
alert('メールタイトルを入力してください');
return;
}if (!body) {
alert('本文を入力してください');
return;
}if (confirm('本当に送信しますか')) {
google.script.run.sendEmails(
subject,
body,
document.getElementById('label').value
);
alert('メールを送信しました');
}
}function confirmCancel() {
if (confirm('本当に終了しますか')) {
google.script.host.close();
}
}
</script>
</body>
</html>
プログラムをチェックしてみる
code.gsをチェックしたところ、バグはなさそう。加えて、GeminiでもChatGPTでも問題になっていたラベルも行けそうなコードになっている。実際には、メールの件名を引っかけてラベルを付けるというプログラムになっているので、件名が全く同じものがあると、きっとラベルが無駄に付いてしまうなと思う。
コードとしては、Copilotが一番良いように思う。
« 東京商工会議所の「東商版 すぐできる! 株価試算」サービス | トップページ | マイクロソフトのイメージクリエイターというAI »
「パソコン・インターネット」カテゴリの記事
- DDoS攻撃で影響を受けたJAL(2024.12.27)
- lumaというイベント開催ツール(2025.01.11)
- パスワード漏洩が増えているらしい(2025.01.04)
- ChatGPT:canvas(2024.12.21)
「AI利用」カテゴリの記事
- マイクロソフトのイメージクリエイターというAI(2024.11.14)
- ChatGPT:canvas(2024.12.21)
- Copilotでもやってみた(2024.11.11)
- ChatGPTではなく、Geminiでもやってみた(2024.11.06)
- メールを配信するプログラム(2024.10.31)
« 東京商工会議所の「東商版 すぐできる! 株価試算」サービス | トップページ | マイクロソフトのイメージクリエイターというAI »
コメント