Mail(SMTP)
SMTP server を Squid に接続し、AI agent と backend code から email を送信します
Mail Connector の Functionality
Mail connector を使用すると、Squid application は任意の SMTP server を通じて email を送信できます。
- Mail connector に接続された AI agent は、user に代わって email を compose・送信できます。たとえば「report を team に email して」と依頼できます。
- Backend code は、attachment 付きの email を含め、programmatically に email を送信できます。
connector は任意の standard SMTP provider と連携します。throttling と sending quota は SMTP provider により管理されます。
Squid Application に Mail Connector を追加する
-
Squid Console の Connectors tab に移動します。
-
Available Connectors をクリックします。
-
Mail connector を見つけ、Add Connector を選択します。
-
次の configuration detail を指定します。
Connector ID: code 内で connector を一意に識別する string。
SMTP Host: smtp.example.com など、SMTP server の hostname。protocol prefix は含めないでください。
SMTP Port: 25、465、587 など、SMTP server の port number。
SMTP Username: SMTP server の authentication に使用する username。
SMTP Password: SMTP server の authentication に使用する password。password は Squid secret として安全に保存されます。email provider が app-specific password を使用する場合は、ここでそれを使用します。
SMTP Encryption: SMTP server への connection に使用する encryption method: tls(default)、ssl、none。
SMTP From Address: send request で sender が指定されない場合に sender として表示される email address。
Application で Mail Connector を使用する
No-code Studio
-
Squid Console の Studio tab に移動します。
-
Create AI Agent をクリックします。
-
"assistant-agent"や"This agent can send emails on the user's behalf"などの agent ID と description を指定します。 -
Add Abilities をクリックします。
-
Mail entry を expand し、先ほど作成した Mail connector を選択します。
-
「user が email の送信を依頼した場合にこれを call する」など、agent がこの connection を使用する方法について description を指定します。
-
Test をクリックし、自分宛てに test email を送信するよう agent に依頼してみます。
Squid SDK を使用する
Squid SDK を使用して AI agent を作成する場合は、ask() function の connectedIntegrations option に Mail connector を追加して接続します。
- TypeScript
- Python
await this.squid
.ai()
.agent('AGENT_ID')
.ask('Send a summary of this conversation to team@example.com', {
connectedIntegrations: [
{
integrationId: 'MAIL_CONNECTOR_ID',
integrationType: 'mail',
description: 'Call this connector to send emails',
},
],
});
await squid.ai().agent('AGENT_ID').ask(
'Send a summary of this conversation to team@example.com',
options={
'connectedIntegrations': [
{
'integrationId': 'MAIL_CONNECTOR_ID',
'integrationType': 'mail',
'description': 'Call this connector to send emails',
}
]
},
)
Backend Code から Email を送信する
programmatic な送信(AI agent tool では利用できない attachment を含む)には、@squidcloud/mail-client package を install し、Squid backend から call します。
npm install @squidcloud/mail-client
import { SquidMailClient } from '@squidcloud/mail-client';
const mail = new SquidMailClient(this.squid);
await mail.sendMail({
integrationId: 'MAIL_CONNECTOR_ID',
to: 'recipient@example.com',
subject: 'Monthly report',
body: '<h1>Report</h1><p>See the attached PDF.</p>',
html: true,
attachments: [
{
filename: 'report.pdf',
content: base64EncodedPdf,
encoding: 'base64',
},
],
});
request から from を省略した場合、connector は構成済みの SMTP From Address を使用します。各 attachment には inline content または backend 上の file への path のいずれかを指定できますが、両方は指定できません。
mail の送信には、executable、scheduler、trigger などの privileged backend context が必要です。unauthenticated client-side call は拒否されます。