Not getting email notifications from topic
I use novu in my laravel app. I configured api key and uri. I created a topic:
$novu->createTopic([
'key' => 'seller_registration_notification',
'name' => $name,
]);
The result is successful.
[2024-02-09 10:16:23] local.INFO: [NovuService][Success]:createTopic {"id":"65c5fb765de7c63123a6da72","key":"seller_registration_notification"}
I created subscriber: $novu->createSubscriber([ 'subscriberId' => 'admin_20', 'email' => '[email protected]', 'firstName' => 'Sapar', 'lastName' => 'Atayev' ]); The result was successful. [2024-02-12 14:21:58] local.INFO: [NovuService][Success]:createSubscriber {"id":"65ca2988619fe4f9cf65013a","subscriberId":"admin_20","firstName":"Sapar","lastName":"Atayev","email":"[email protected]","channels":[],"organizationId":"6409c0dbe5d10c2178942df2","environmentId":"6409c0dbe5d10c2178942e1c","deleted":false,"createdAt":"2024-02-12T14:22:00.538Z","updatedAt":"2024-02-12T14:22:00.538Z","v":0} Added subscriber to topic: $novu->topic('seller_registration_notification')->addSubscribers(['admin_20']); Result is successful. [2024-02-12 14:21:59] local.INFO: [NovuService][Success]:addSubscribersToTopic {"succeeded":["admin_20"]} Created workflow manually through interface. Workflow ID is 'lpb-new-seller'. I added the step 'Email' in order to send email notification. Configured the email template in workflow. Sent notification to topic: $novu->triggerEvent([ 'name' => 'lpb-new-seller', 'to' => [ [ 'type' => 'Topic', 'topicKey' => 'seller_registration_notification' ], ], 'payload' => [ 'info' => 'info', 'name' => 'Mr. John', ] ]) Success. Novu activity feed shows success. But I don't receive any email to subscriber mail box. [2024-02-13 07:44:32] local.INFO: [NovuService][Success]:sendNotificationToTopics {"transactionId":"70544a21-28a8-49b1-9ce5-11bb7468627b","acknowledged":true,"status":"processed"} Need help. Thanks.
I created subscriber: $novu->createSubscriber([ 'subscriberId' => 'admin_20', 'email' => '[email protected]', 'firstName' => 'Sapar', 'lastName' => 'Atayev' ]); The result was successful. [2024-02-12 14:21:58] local.INFO: [NovuService][Success]:createSubscriber {"id":"65ca2988619fe4f9cf65013a","subscriberId":"admin_20","firstName":"Sapar","lastName":"Atayev","email":"[email protected]","channels":[],"organizationId":"6409c0dbe5d10c2178942df2","environmentId":"6409c0dbe5d10c2178942e1c","deleted":false,"createdAt":"2024-02-12T14:22:00.538Z","updatedAt":"2024-02-12T14:22:00.538Z","v":0} Added subscriber to topic: $novu->topic('seller_registration_notification')->addSubscribers(['admin_20']); Result is successful. [2024-02-12 14:21:59] local.INFO: [NovuService][Success]:addSubscribersToTopic {"succeeded":["admin_20"]} Created workflow manually through interface. Workflow ID is 'lpb-new-seller'. I added the step 'Email' in order to send email notification. Configured the email template in workflow. Sent notification to topic: $novu->triggerEvent([ 'name' => 'lpb-new-seller', 'to' => [ [ 'type' => 'Topic', 'topicKey' => 'seller_registration_notification' ], ], 'payload' => [ 'info' => 'info', 'name' => 'Mr. John', ] ]) Success. Novu activity feed shows success. But I don't receive any email to subscriber mail box. [2024-02-13 07:44:32] local.INFO: [NovuService][Success]:sendNotificationToTopics {"transactionId":"70544a21-28a8-49b1-9ce5-11bb7468627b","acknowledged":true,"status":"processed"} Need help. Thanks.
33 Replies
Can you try with small "topic"
what do you mean "small"?
Change Topic with topic
'type' => 'topic'
@Pawan Jain it didn't help
{"transactionId":"948a7dcf-77a5-4909-9d16-77db6f04dc3f","acknowledged":true,"status":"processed"}
@Sapar let me check the logs
Thanks for sharing the transactionId
@Sapar
In logs, I see this error
@unicodeveloper can you please with correct payload to trigger to a topic
@Pawan Jain Iam a little bit confused. according to the documentation
// Send notifications to a topic (all frontend users)
$novu->triggerEvent([
'name' => 'first-email',
'to' => [
[
'type' => 'Topic',
'topicKey' => 'frontend-users'
]
]
])->toArray();
it has nothing to do with subscriberId here in trigger
@Sapar, you just advanced to level 1!
This is correct
How many subscribers are added to your topic? @Sapar
@unicodeveloper I added two subscribers to topic
Can anyone help me?
I am checking this today to see what might be wrong. One question for you. When you were creating the subscribers, are you sure you added the id property? or was it email you added?
I add an array of ids
$novu->topic($topicKey)->addSubscribers(['admin_19', 'admin_20']);
when I create subscribers:
$novu->createSubscriber([
'subscriberId' => config('novu.novu_admin_subscriberprefix') . '' . $user->id,
'email' => $user->email,
'firstName' => $user->first_name,
'lastName' => $user->last_name
]);
when I create subscribers, I add subscriberId and email too @unicodeveloper
can you check the list of subscribers to be sure it returns both subscriberId and email? @Sapar
@unicodeveloper yes, sure, here is the api response
{
"_id": "65c9f3f3b637cdb23e529aac",
"_organizationId": "6409c0dbe5d10c2178942df2",
"_environmentId": "6409c0dbe5d10c2178942e1c",
"firstName": "Sopa",
"lastName": "Atayev",
"subscriberId": "admin_19",
"email": "[email protected]",
"channels": [],
"deleted": false,
"createdAt": "2024-02-12T10:33:23.407Z",
"updatedAt": "2024-02-14T07:21:54.917Z",
"v": 0
},
{
"_id": "65ca2988619fe4f9cf65013a",
"_organizationId": "6409c0dbe5d10c2178942df2",
"_environmentId": "6409c0dbe5d10c2178942e1c",
"firstName": "Sapar",
"lastName": "Atayev",
"subscriberId": "admin_20",
"email": "[email protected]",
"channels": [],
"deleted": false,
"createdAt": "2024-02-12T14:22:00.538Z",
"updatedAt": "2024-02-14T07:21:54.927Z",
"v": 0
}
@Sapar I just tested it on my end and it works as intended. So this is really strange 🤔
and?
I want you to do me a favor and try with only number ids. e.g
445
or 88888
. I want to verify something@Sapar, you just advanced to level 2!
@Prosper do you mean 445 instead of "admin_20"?
yes
I mean this should not affect it but we want to rule out all options. Does your activity feed give you any error for the transactions?
@Sapar I see you have these subscribers admin_19 and admin_20 having different emails
Could you check if emails are going to spam folder?
@unicodeveloper yes, ok, I'm working on it, I'll add subscribers with numeric ids and I;ll let you know
@Pawan Jain sure I checked spam folders, there are no messages
in both mail boxes
@unicodeveloper @Pawan Jain I created subscriber with Id 3775, created new topic, add him to topic, and sent notification to topic.
{"transactionId":"8f074595-fdaa-47e9-b765-62b05286cf50","acknowledged":true,"status":"processed"}
I see there is only one subscriber in the topic
and email is sent from our side
@unicodeveloper @Pawan Jain activity feed has new item:
transaction Id: 8f074595-fdaa-47e9-b765-62b05286cf50
@Pawan Jain yes, I added only one subsciber, did everything from scratch, shared response from api, and from activity feed
did you receive the email?
@unicodeveloper no
@Pawan Jain confirmed that the email was sent from our end. What email provider are you using?
@unicodeveloper
{
"providerId": "novu-email",
"identifier": "novu-email-G-sfycO38C",
"name": "Novu Email",
"_environmentId": "6409c0dbe5d10c2178942e1c",
"_id": "64da408c88468b9fd36f56e0"
}
@unicodeveloper @Pawan Jain I sent an email notification simply - to a subscriber, in this case I didn't get a message too
{
"data": {
"acknowledged": true,
"status": "processed",
"transactionId": "9fa32c68-f444-4b23-8720-98844fc81f1b"
}
}
Even though the activity feed shows SUCCESS
any ideas with that?
@unicodeveloper @Pawan Jain I regenerated API key and repeated sending email message to subscriber, as a result got error:
{
"message": "Bad Request",
"code": 400,
"response": {
"headers": {
"server": "nginx",
"date": "Wed, 14 Feb 2024 12:55:25 GMT",
"content-type": "application/json",
"content-length": "204",
"connection": "keep-alive",
"access-control-allow-origin": "https://sendgrid.api-docs.io",
"access-control-allow-methods": "POST",
"access-control-allow-headers": "Authorization, Content-Type, On-behalf-of, x-sg-elas-acl",
"access-control-max-age": "600",
"x-no-cors-reason": "https://sendgrid.com/docs/Classroom/Basics/API/cors.html",
"strict-transport-security": "max-age=600; includeSubDomains"
},
"body": {
"errors": [
{
"message": "Does not contain a valid address.",
"field": "personalizations.0.to.0.email",
"help": "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.personalizations.to"
}
]
}
}
}
{
"providerId": "novu-email",
"identifier": "novu-email-G-sfycO38C",
"name": "Novu Email",
"_environmentId": "6409c0dbe5d10c2178942e1c",
"_id": "64da408c88468b9fd36f56e0"
}
transactionId: 21fd96aa-b36b-41f2-b185-033f17473623