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

params is ignored when messageVersions is set for a single recipient #46

Open
frederico-rmt opened this issue Jan 13, 2025 · 0 comments

Comments

@frederico-rmt
Copy link

I'm using brevo on my application to send email with an template ID with the following body parameters: templateID, params and messageVersions. I have a script that creates a dynamic messageVersions, it can send from a single to multiple contacts, each contact should receive a individual message version with its name.

While testing sending to multiple contacts i always made the following request and everything was replaced when the email was sended.

const email = {
    templateId: 37,
    messageVersions: [{
      to: [{"email":"[email protected]"}],
      params: {"recipientName": "Frederico", "recipientCity":"São Paulo"}
      },
      {
      to: [{"email":"[email protected]"}],
      params: {"recipientName": "Lucas", "recipientCity":"Rio de Janeiro"}
      }
    ],
    params: {"deadline":"13/12/2011", "cost":"R$ 1234,56"}
  };

But when i tested for a single contact the global params was not replaced and only the info in the messageVersions.

const email = {
    templateId: 37,
    messageVersions: [{
      to: [{"email":"[email protected]"}],
      params: {"recipientName": "Frederico", "recipientCity":"São Paulo"}
      },
    ],
    params: {"deadline":"13/12/2011", "cost":"R$ 1234,56"}
  };

Is it a expected behavior ? It looks like that the messageVersions params become the global params and the real one is ignored.

Unfortanely with this behavior founded by us, now we are making a full request on every messageVersions like this, because often we are sending email to only one recipient:

const email = {
    templateId: 37,
    messageVersions: [{
      to: [{"email":"[email protected]"}],
      params: {"recipientName": "Frederico", "recipientCity":"São Paulo", "deadline":"13/12/2011", "cost":"R$ 1234,56"}
      },
      {
      to: [{"email":"[email protected]"}],
      params: {"recipientName": "Lucas", "recipientCity":"Rio de Janeiro", "deadline":"13/12/2011", "cost":"R$ 1234,56"}
      }
    ]
  };
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