Hello,
I want to use SendGrid dynamic templates along with code first workflows and digest as one of the steps.
The problem I am facing is that we need to pass in the templateId and the dynamic data when triggering the workflow. Is there a way to pass in the digestResult to the SendGrid template?
13 Replies
Hi @Dragan, I'm an AI assistant for Novu. While a team member reviews this question, I'll see if I can find relevant sources for your question.
-----------------------------
While I generate an answer, here are some sources that might be helpful:
* SendGrid
* Collect multiple events to a single message with the Digest Engine
* Digest Action Step
* How to Add Digest to Email Notifications
-----------------------------
Answer
Yes, it is possible to use SendGrid dynamic templates with code-first workflows and digest steps in Novu. (1) You can pass the SendGrid template ID and dynamic data when triggering the workflow using the
customData
field in the email overrides. Using SendGrid Templates
To use a SendGrid template, you can include the template details in the customData
field of the email overrides when triggering the workflow. Here's an example of how you can do this:
Passing Digest Results
To pass the digest results to the SendGrid template, you can use the digest step in your workflow and then access the digest results in the subsequent email step. (2) Here's how you can structure your workflow:
1. Define a digest step in your workflow. 2. In the email step after the digest, you can access the digest results and include them in the dynamicTemplateData
. Here's an example of how you might structure this in your workflow:Feel free to tag @Ask Inkeep with additional questions.
@Dragan
Here you are looking to use SendGrid dynamic templates or just want to change email content text while triggering?
in case of sendgrid dynamic template, templateId and dynamic data is required filed, you can use digestResult response in dynamicdata
@Pawan Jain I am trying to use SendGrid dynamic template. I just can't get the data from the email step. The above solution did not work.
await step.email('send-email', async () => {
return {
subject: 'New email',
body: '',
customData: {
templateId: 'sendgrid-template-id',
dynamicTemplateData: {
name: 'some data',
updatedBy: 'John Wick',
},
},
};
});
I this is my step definition
but I don't seem to get the values in sendgrid
this is what is sent based on the activity feed:
{
"name": "some-workflow",
"to": {
"subscriberId": "2"
},
"payload": {
"name": "Name1",
"updatedBy": "Dragan"
},
"overrides": {
"email": {
"customData": {
"templateId": "sendgrid-template-id",
"dynamicTemplateData": {
"name": "Name from trigger"
}
}
}
}
}
@Dragan, you just advanced to level 1!
when I get the mail only the variables from the overrides are populated
the dynamicTemplateData from the email step never seem to make it to sendgrid
Hi @Dragan !
This will be possible with step provider overrides in the framework SDK:
https://docs.novu.co/sdks/framework/typescript/steps/introduction#providers-overrides-object
Unfortuently we only support passing the the ipPoolName at the moment
In about 1-2 weeks, we will release the interface to pass any provider custom SDK properties (including all the other Sendgrid available SDKS)
I will update you once this becomes available 🙏
Here is the interface for when it's available
Hi @Dima Grossman , thanks for the clarification.
As a side note: the chatbot gives false/inaccurate data for this topic.
Yes ^
@Pawan Jain can we reindex the bot or disable it?