N
Novu•9mo ago
ninadk

User avatar not uploaded

I'm updating the user info passing in a link for the user avatar, but the avatar field doesn't show at all in the update response (or get), and the avatar doesn't display in the UI. Here's part of the code and the outputs from what the input and output data looks like:
const res = await novu.subscribers.update(subscriberId, {
firstName,
lastName,
email,
avatar: imageUrl,
});
const res = await novu.subscribers.update(subscriberId, {
firstName,
lastName,
email,
avatar: imageUrl,
});
{
subscriberId: '2',
firstName: 'Antonina',
lastName: 'K',
avatar: 'https://res.cloudinary.com/dwlk6urra/image/upload/v1710605561/profile-pics/2'
}
{
subscriberId: '2',
firstName: 'Antonina',
lastName: 'K',
avatar: 'https://res.cloudinary.com/dwlk6urra/image/upload/v1710605561/profile-pics/2'
}
{
subscriberInfo: {
_id: 'user-id',
_organizationId: 'my-id',
_environmentId: 'my-env-id',
firstName: 'Antonina',
lastName: 'K',
subscriberId: '2',
channels: [],
data: { username: 'antonina' },
deleted: false,
createdAt: '2024-03-13T08:30:28.218Z',
updatedAt: '2024-03-17T12:30:18.023Z',
__v: 0,
isOnline: false,
lastOnlineAt: '2024-03-17T12:30:17.661Z',
id: 'user-id'
}
}
{
subscriberInfo: {
_id: 'user-id',
_organizationId: 'my-id',
_environmentId: 'my-env-id',
firstName: 'Antonina',
lastName: 'K',
subscriberId: '2',
channels: [],
data: { username: 'antonina' },
deleted: false,
createdAt: '2024-03-13T08:30:28.218Z',
updatedAt: '2024-03-17T12:30:18.023Z',
__v: 0,
isOnline: false,
lastOnlineAt: '2024-03-17T12:30:17.661Z',
id: 'user-id'
}
}
Note that the other info is updated successfully. I've also activated the avatar and selected "user avatar" for this workflow in the dashboard. Am I missing something here?
24 Replies
Ask Inkeep
Ask Inkeep•9mo ago
Hi @ninadk, I'm an AI assistant knowledgeable about Novu. While a team member is able to review this question, I'll look through relevant sources and see if I can provide suggestions. Please tag @Ask Inkeep with any follow-up questions. ----------------------------- While I generate an answer, here are some sources that might be helpful: * Update subscriber * General * iFrame * Iframe Embed -----------------------------
Ask Inkeep
Ask Inkeep•9mo ago
Answer Based on the details provided and the Novu documentation, when updating a subscriber using the Novu API, including the avatar field is supported and should reflect in the update response. As seen in the documentation for updating a subscriber, the avatar field is a string and is part of the expected fields that can be updated. If the avatar field is not appearing in the update response or the Novu UI as expected, and other information is updated successfully, it might indicate an issue with how the avatar update is processed or displayed by Novu. Given the circumstances, there are a few steps you can consider: 1. Ensure that the URL for the avatar image is accessible and correctly formatted. The avatar field expects a string, which should be a valid URL to the image. 2. Double-check that the avatar functionality is correctly enabled in your Novu dashboard settings for it to display in the UI. 3. Since the avatar does not display despite being activated in the dashboard, there might be a bug or a specific issue with the Novu system handling avatar updates. As your situation appears to be specific and does not seem to align with expected behavior according to the documentation, it's recommended to reach out to Novu support or file a bug report. Given that this situation involves expected functionality not performing as documented, Novu's support team or the community might provide further insights or workarounds. Note: The documentation does not explicitly mention any additional steps required for the avatar to be displayed in the UI after an update. If all steps have been correctly followed on your end, seeking support directly from Novu might be the best course of action to resolve this issue (1) .
Ask Inkeep
Ask Inkeep•9mo ago
Got it. Tagging @Support for additional help.
Gali Baum
Gali Baum•9mo ago
You mean you set user avatar here? @ninadk
No description
ninadk
ninadkOP•9mo ago
Yeap
Novu_Bot
Novu_Bot•9mo ago
@ninadk, you just advanced to level 1!
Gali Baum
Gali Baum•9mo ago
That will add the avatar of the actor, not the current subscriber https://docs.novu.co/additional-resources/glossary#actor
Novu
Glossary - Novu
Definitions
Gali Baum
Gali Baum•9mo ago
try adding to the trigger you are executing
novu.trigger(....,
payload: {...},
actor: { subscriberId: '2'} )
novu.trigger(....,
payload: {...},
actor: { subscriberId: '2'} )
let me know how that goes 🙂 @ninadk
ninadk
ninadkOP•9mo ago
This is my code for triggering the notification:
await novu.trigger('join-neighborhood', {
to: {
subscriberId: adminId,
},
actor: {
subscriberId: userId,
},
payload: {
neighborhoodId,
neighborhoodName,
username,
userId,
},
});
await novu.trigger('join-neighborhood', {
to: {
subscriberId: adminId,
},
actor: {
subscriberId: userId,
},
payload: {
neighborhoodId,
neighborhoodName,
username,
userId,
},
});
I believe the issue is that the avatar doesn't even get set, though, as shown in the return of the update method I pasted above (3rd snippet).
Pawan Jain
Pawan Jain•9mo ago
@ninadk could you please share environmentId from settings?
ninadk
ninadkOP•9mo ago
sure 659fb61f76272e378b87e463
Pawan Jain
Pawan Jain•9mo ago
@ninadk Thanks for sharing the environmentId i can check from logs that you have created subscriber with subscriberId 2 few times and then deleted. Did you try updating the current subscriber with subscriberId 2?
ninadk
ninadkOP•9mo ago
Yes, I did. This could be because every time I re-seed the database I also delete all subscribers and re-create them. I just tried again. I can see the other information I'm updating on my subscribers dashboard, but not the avatar.
Pawan Jain
Pawan Jain•9mo ago
@ninadk Could you please try directly with our API? https://docs.novu.co/api-reference/subscribers/update-subscriber
ninadk
ninadkOP•9mo ago
That worked! I tried it directly on your website. Should I use a fetch instead of the update method then?
Pawan Jain
Pawan Jain•9mo ago
its a bit strange, do you see the similar bahaviour with other subscribers?
ninadk
ninadkOP•9mo ago
Yes I just checked. Though i wasn't able to do the same using a fetch request programmatically:
const subscriberInfo = { firstName, lastName, email, avatar: imageUrl };

const options = {
method: 'PUT',
headers: { Authorization: `ApiKey ${NOVU_API_KEY}` },
body: JSON.stringify(subscriberInfo),
};

const res = await fetch(`https://api.novu.co/v1/subscribers/${subscriberId}`, options)
.then((response) => response.json())
.then((response) => response.data)
.catch((err) => {
console.error(err);
return { error: `Could not update subscriber ${subscriberId}.` };
});
const subscriberInfo = { firstName, lastName, email, avatar: imageUrl };

const options = {
method: 'PUT',
headers: { Authorization: `ApiKey ${NOVU_API_KEY}` },
body: JSON.stringify(subscriberInfo),
};

const res = await fetch(`https://api.novu.co/v1/subscribers/${subscriberId}`, options)
.then((response) => response.json())
.then((response) => response.data)
.catch((err) => {
console.error(err);
return { error: `Could not update subscriber ${subscriberId}.` };
});
Pawan Jain
Pawan Jain•9mo ago
@ninadk could you please check if imageUrl is null or a valid string?
ninadk
ninadkOP•9mo ago
It is valid.
subscriberInfo: {
firstName: 'shwetank',
lastName: '',
avatar: 'https://res.cloudinary.com/dwlk6urra/image/upload/v1710605561/profile-pics/antonina:2'
}
subscriberInfo: {
firstName: 'shwetank',
lastName: '',
avatar: 'https://res.cloudinary.com/dwlk6urra/image/upload/v1710605561/profile-pics/antonina:2'
}
And the other information is not updated either with the fetch.
ninadk
ninadkOP•9mo ago
Good to know! It's a valid url though. Could you help me out re the fetch call? Am I doing something wrong there?
Novu_Bot
Novu_Bot•9mo ago
@ninadk, you just advanced to level 2!
Gali Baum
Gali Baum•9mo ago
@ninadk can you please try without the stringify of the body?
ninadk
ninadkOP•9mo ago
Still no lack... Here's the updated code:
const subscriberInfo = { firstName, lastName, email, avatar };

const options = {
method: 'PUT',
headers: { Authorization: `ApiKey ${NOVU_API_KEY}` },
body: subscriberInfo as unknown as BodyInit,
};

const res = await fetch(`https://api.novu.co/v1/subscribers/${subscriberId}`, options)
.then((response) => response.json())
.then((response) => response.data)
.catch((err) => {
console.error(err);
return { error: `Could not update subscriber ${subscriberId}.` };
});
const subscriberInfo = { firstName, lastName, email, avatar };

const options = {
method: 'PUT',
headers: { Authorization: `ApiKey ${NOVU_API_KEY}` },
body: subscriberInfo as unknown as BodyInit,
};

const res = await fetch(`https://api.novu.co/v1/subscribers/${subscriberId}`, options)
.then((response) => response.json())
.then((response) => response.data)
.catch((err) => {
console.error(err);
return { error: `Could not update subscriber ${subscriberId}.` };
});
And what subscriberInfo looks like:
{
firstName: 'Radu',
lastName: 'A C',
avatar: 'https://hips.hearstapps.com/hmg-prod/images/beautiful-smooth-haired-red-cat-lies-on-the-sofa-royalty-free-image-1678488026.jpg'
}
{
firstName: 'Radu',
lastName: 'A C',
avatar: 'https://hips.hearstapps.com/hmg-prod/images/beautiful-smooth-haired-red-cat-lies-on-the-sofa-royalty-free-image-1678488026.jpg'
}
The image URL is random. I tried updating the lastName this time, but it didn't work.
Want results from more Discord servers?
Add your server