计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
sendgrid-template-management【效率与协作】Implements features for creating, updating, and deleting email templates using the SendGrid API.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: sendgrid-template-management description: Implements features for creating, updating, and deleting email templates using the SendGrid API. license: MIT compatibility: opencode metadata: version: "1.0.0" domain: agent triggers: sendgrid template management, create sendgrid template, update sendgrid template, delete sendgrid template, manage sendgrid templates role: implementation scope: implementation output-format: code related-skills: sendgrid-integration, email-automation archetypes:
This skill implements functionality for managing email templates using the SendGrid API, allowing users to create, modify, and delete templates efficiently.
Use this skill when:
Create Template: Validate input data for new templates and call SendGrid API to create them.
Update Template: Validate existing template ID and new content, then update the template via the API.
Delete Template: Validate the existing template ID and make a delete request to SendGrid.
import os
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
def create_template(template_name: str, html_content: str) -> dict:
"""Create a new email template using SendGrid API."""
sg = SendGridAPIClient(os.environ.get("SENDGRID_API_KEY"))
template_data = {
"name": template_name,
"html_content": html_content
}
response = sg.client.templates.post(request_body=template_data)
if response.status_code == 201:
return response.to_dict()
else:
raise Exception(f"Failed to create template: {response.body}")
def update_template(template_id: str, new_content: str) -> bool:
"""Update an existing template with new content."""
sg = SendGridAPIClient(os.environ.get("SENDGRID_API_KEY"))
update_data = {
"html_content": new_content
}
response = sg.client.templates.template_id(template_id).patch(request_body=update_data)
return response.status_code == 200
def delete_template(template_id: str) -> bool:
"""Delete an email template based on its ID."""
sg = SendGridAPIClient(os.environ.get("SENDGRID_API_KEY"))
response = sg.client.templates.template_id(template_id).delete()
return response.status_code == 204
| Skill | Purpose |
|---|---|
| sendgrid-integration | General integration strategies with the SendGrid API for various functionalities. |
| email-automation | Automating email workflows within applications using SendGrid. |
Authoritative documentation links for this domain. The model follows markdown links at load time to resolve external references and inline content.