N
Novuβ€’6mo ago
artiebay

Multi-tenant + Pushpad for Push Notifications (Active blocker for our development!)

Hey everyone. I work at Bask, which you guys actually have featured in your homepage! We are trying to use Novu as a way to deliver push notifications via Pushpad. But as a white-label application, we have a multi-tenant architecture. To accomplish this, I am planning on the following: - Use a different tenant on Novu for each of our tenants - Add a different Integration in the Integration page, per tenant as well - Each integration links to a different Pushpad Sender/Project (Different ProjectID) To accomplish the above, we need the following: - An API that allows us to create a Tenant without using the Dashboard <- This is essential. I don't see it in the API Reference docs. Any multi-tenant architecture would require an API actually. Impossible to manage manually - An API that allows us create a new integration and set a condition for the tenant <- This looks like it is already supported, but I would appreciate an example for the payload since I don't see it in the API Reference Docs an option for a "Tenant". Also, a couple of additional questions: - Is there a hard cap on how many active "Integrations" we can have? This could be a problem as we have more tenants support push notifications for their users - Is there maybe another to pass the "ProjectID" to Pushpad a different way? Maybe when we call https://api.novu.co/v1/events/trigger we can just specify it in the body somehow. This could be a workaround from the need of tenants and all of the above (Since we internally keep the project/sender id) We could use Webhooks to implement this and forward to Pushpad ourselves / keep push tokens internally. But it would defeat a lot of the purpose of using Novu to broker our user-facing notifications
12 Replies
artiebay
artiebayOPβ€’6mo ago
Bump
Pawan Jain
Pawan Jainβ€’6mo ago
@artiebay Apologies for delay in response I am looking into these two APIs @artiebay - Checkout this API to create tenant https://v0.x-docs.novu.co/api-reference/tenants/create-tenant - Checkout this curl request to create integration with tenant condition _environmentId is of mongodb id type. Let me know if you need help in finding values for your development and production environment
curl -L -X POST 'https://api.novu.co/v1/integrations' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: ApiKey NOVU_SECRET_KEY' \
-d '{
"providerId": "pushpad",
"channel": "push",
"name": "CUSTOM_NAME_OF_INTEGRATION_HERE",
"credentials": {
"apiKey": "PUSHPAD_TOKEN",
"applicationId": "PUSHPAD_PROJECT_ID"
},
"active": true,
"check": false,
"conditions": [
{
"children": [
{
"operator": "EQUAL",
"on": "tenant",
"field": "identifier",
"value": "TENANT_IDENTIFIER_VALUE_HERE"
}
]
}
],
"_environmentId": "ENVIRONMENT_ID"
}'
curl -L -X POST 'https://api.novu.co/v1/integrations' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: ApiKey NOVU_SECRET_KEY' \
-d '{
"providerId": "pushpad",
"channel": "push",
"name": "CUSTOM_NAME_OF_INTEGRATION_HERE",
"credentials": {
"apiKey": "PUSHPAD_TOKEN",
"applicationId": "PUSHPAD_PROJECT_ID"
},
"active": true,
"check": false,
"conditions": [
{
"children": [
{
"operator": "EQUAL",
"on": "tenant",
"field": "identifier",
"value": "TENANT_IDENTIFIER_VALUE_HERE"
}
]
}
],
"_environmentId": "ENVIRONMENT_ID"
}'
- Currently, there is no any limit on number of integrations. Would you like to share approx how many integrations you are going to create? - sending pushpad project id while triggering the workflow: let me know if you need this feature after above configiuration @artiebay Just want to follow up if you have any question
artiebay
artiebayOPβ€’6mo ago
@Pawan Jain Thank you πŸ™ . I'm back on working on this today. If I hit a roadblock on the multi-tenant approach I will let you know!
Pawan Jain
Pawan Jainβ€’5mo ago
Sure @artiebay πŸ™ŒπŸ» @artiebay unlocked the post
artiebay
artiebayOPβ€’5mo ago
@Pawan Jain We have reached a point where we can create the tenants via an API. However, right now all our workflows automatically use an integration associated with a given tenant which is the first one we create (it happened automatically). We need a way to associate a tenant after created with the workflows just for that tenants. Or the correct Pushpad integration for that specific workflows has to be the one that matches that tenants. How can we accomplish that? I don’t see a way to associate a workflow with a tenants. Or a way to manage which integration a workflow uses via an api. @Pawan Jain One thing worth noting. Right now we are creating an integration on Novu per tenant. When we add device tokens for a "Novu subscriber", we use the integration ID for that tenant. So. Let's say we have an user U, a tenant T and a workflow W for T. Right now when when U has an event, and we trigger W. We pass the the subscriber ID for U to the trigger. This is where we are fetching the device token from also. When we add device tokens to U, we are adding them by integration ID. So U has a channel with an integration ID for the integration of T specifically ! Does this mean we can potentially pass that integration ID every time we trigger that workflow as well when we call Novu? Same as we have subscriber ID for U?
Pawan Jain
Pawan Jainβ€’5mo ago
@artiebay You can pass tenant identifier while triggering the workflow
curl -X POST "https://api.novu.co/v1/events/trigger" \
-H "Authorization: ApiKey <NOVU_SECRET_KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "workflow_identifier",
"payload": {
"comment_id": "string",
"post": {
"text": "string"
}
},
"to": {
"subscriberId": "SUBSCRIBER_ID"
}
// here πŸ‘‡πŸ»
"tenant": "tenant-identifier"
}'
curl -X POST "https://api.novu.co/v1/events/trigger" \
-H "Authorization: ApiKey <NOVU_SECRET_KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "workflow_identifier",
"payload": {
"comment_id": "string",
"post": {
"text": "string"
}
},
"to": {
"subscriberId": "SUBSCRIBER_ID"
}
// here πŸ‘‡πŸ»
"tenant": "tenant-identifier"
}'
Based on the tenant condition on integration, particular pushpad integration will be used to send push notification
artiebay
artiebayOPβ€’5mo ago
@Pawan Jain Awesome. Just double-checkin. So if I have several integrations created, one for each Project/Sender Pushpad integration. The integration that will be selected for Pushpad for that workflow will be manually auto-configured to the right one?
Novu_Bot
Novu_Botβ€’5mo ago
@artiebay, you just advanced to level 1!
Pawan Jain
Pawan Jainβ€’5mo ago
Yes, if you have added tenant condition with integration and tenant value is sent with workflow trigger
artiebay
artiebayOPβ€’5mo ago
@Pawan Jain I'm a bit confused. On this doc I can pass an integrationIdentifier : https://v0.x-docs.novu.co/api-reference/subscribers/update-subscriber-credentials But also, based on above. It is the tenantId that we pass to the workflow that helps with the "routing" decision on which Pushpad integration to be used. In this scenario, how is the integration identifier relevant? Is it to device which device tokens to be sent? In other words. Does the integrationId for the channel that the subscriber has the device tokens in also has match the integration that has that matching tenantId condition?
Pawan Jain
Pawan Jainβ€’5mo ago
@artiebay Yes, integrationIdentifier is used to identify for which integration, deviceToken will be saved. As there could be many pushpad integrations
Does the integrationId for the channel that the subscriber has the device tokens in also has match the integration that has that matching tenantId condition?
Yes, the subscriber must have device tokens for that particular subscriber
artiebay
artiebayOPβ€’5mo ago
@Pawan Jain Thank you so much! We took this home! We sucessfully implemented a push multi-tenant feature linking to Novu then Pushpad. The purpose of this thread is fullfiled. Can I give you a positive recommendation somewhere? Not all heroes wear capes sir :).

Did you find this page helpful?