Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Receive Custom Arguments in Event Webhook #1419

Open
KentaYamada opened this issue Oct 23, 2024 · 0 comments
Open

How to Receive Custom Arguments in Event Webhook #1419

KentaYamada opened this issue Oct 23, 2024 · 0 comments

Comments

@KentaYamada
Copy link

Hi, all.

I would like to set custom arguments in the request using the Node.js SDK and receive them in the Event Webhook, but I'm unable to receive them correctly. Could you please provide guidance on how to implement this?

Package versions

  • node: 18.20
  • @sendgrid/mail: 8.1.3

source code (typescript)

// Send email
const service = new MailService();
service.send({
   from: `Cafe de Gamoyon<${process.env.FROM}>`,
   to: payload.mail,
   bcc: bcc,
   subject: mailTemplate.subject,
   text: text,
  // is that correct ?
  customArgs: {
      mail_notification_id: mailNotificationId,
    },
});

// Define event webhook payload type
type SendgridEvent = {
  email: string;
  timestamp: Date;
  "smtp-id": string;
  event: string;
  sg_event_id: string;
  sg_message_id: string;
  category?: string | string[];
  response: string;
} & Partial<Record<string, string>>;

expected

{
  "email": "xxx",
  "timestamp": "xxx",
  "smtp-id":  "xxx",
  "event": "xxx",
  "sg_event_id": "xxx",
  "sg_message_id": "xxx",
  "category": "xxx",
  "response": "xxx",
  "mail_notification_id": "xxx"
}

actual
スクリーンショット 2024-10-23 19 11 48

When I looked at the sample code, custom arguments were set in the personalizations. Is this the only way to receive them in the Event Webhook?
https://www.twilio.com/docs/sendgrid/for-developers/tracking-events/event#custom-arguments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant