
Email Notification Webhook
Pricing
Pay per usage
Go to Store

Email Notification Webhook
This actor sends you an email notification with a log file when one of your other actors fails, succeeds, times out, you name it.
0.0 (0)
Pricing
Pay per usage
5
Total users
52
Monthly users
2
Runs succeeded
97%
Last modified
2 years ago
Dockerfile
FROM apify/actor-node-basic# Copy source codeCOPY . ./#COPY src ./srcRUN npm --quiet set progress=false \&& npm install --only=prod --no-optional \&& echo "Installed NPM packages:" \&& npm list || true \&& echo "Node.js version:" \&& node --version \&& echo "NPM version:" \&& npm --version
main.js
1const Apify = require('apify');2
3const { client, utils: { log } } = Apify;4
5Apify.main(async () => {6 log.info('Getting IDs of the calling actor and run.');7 let { 8 eventData: { actorId, actorRunId },9 resource: { status },10 notificationEmail,11 } = await Apify.getInput();12
13 log.info('Getting actor\'s identifier.');14 const { name, username } = await client.acts.getAct({ actId: actorId });15 const identifier = `${username}/${name}`;16 17 log.info(`Using run id: ${actorRunId} to download log file.`);18 const runLog = await client.logs.getLog({ logId: actorRunId });19
20 if (!notificationEmail) {21 log.info('Getting email of the calling user.');22 const { email } = await client.users.getUser();23 notificationEmail = email;24 }25 26 log.info(`Sending email to: ${notificationEmail}`);27 await Apify.metamorph('e643gqfZae2TfQEbA', { // ID of apify/send-mail28 to: notificationEmail,29 subject: `Apify actor ${identifier} ${status}`,30 html: `<p>Run <strong>${actorRunId}</strong> of the actor <strong>${identifier}</strong>`31 + ` (${actorId}) finished with status: <strong>${status}</strong>.</p>`32 + '<p>You can find the run\'s log in the attached file:</p>\n\n',33 attachments: [{34 filename: 'log.txt',35 data: Buffer.from(runLog).toString('base64'),36 }],37 }, { build: 'latest' });38});
package.json
{ "name": "email-notification-webhook", "version": "0.0.1", "description": "This actor sends you an email notification with a log file when one of your other actors fails, succeeds, times out, you name it.", "main": "main.js", "dependencies": { "apify": "latest" }, "scripts": { "start": "node main.js" }, "author": "mnmkng"}