import { IncidentsService } from '@grafana/incident'; import { send, setApiKey } from '@sendgrid/mail'; async function emailOnNewIncident({ token, incidentID }) { const service = new IncidentsService({ token }); const incident = await service.getIncident({ incidentID }); setApiKey(env.SENDGRID_API_KEY); const message = { to: 'incident-announce@example.com', from: 'noreply-grafana-script@grafana.com', subject: `new incident: ${incident.title}`, text: 'New incident has been declared', }; const response = await send(message); console.log(response); } emailOnNewIncident(args[1]);