Skip to content

Commit

Permalink
Merge pull request #2 from tago-io/fix-notification
Browse files Browse the repository at this point in the history
fix: add more instructions
  • Loading branch information
felipefdl authored Aug 4, 2020
2 parents 97633b8 + 6d1b3c7 commit 4e3b34f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,26 @@ const { Analysis, Services, Utils } = require("@tago-io/sdk");
/**
* The main function used by Tago to run the script.
* It sends a notification to the account and another one linked to a dashboard.
* Optional: You can set a dashboard_id using an environment variable
* this will show a button on the notification to send the user directly to the dashboard
*/
async function sendNotification(context) {
// reads the values from the environment variables and saves it in the variable env_vars
const env_var = Utils.envToJson(context.environment);

const notification = new Services({ token: context.token }).Notification;

// In this variable, you type the title of the notification
const title = 'Your title';

// In this variable, you type the message that you will send on the notification
const message = 'Your message';

try {
const service_response = await notification.send({
message: env_var.message,
title: env_var.title,
ref_id: env_var.dashboard_id || env_var.bucket_id || undefined,
message,
title,
ref_id: env_var.dashboard_id || undefined,
});

context.log(service_response);
Expand Down

0 comments on commit 4e3b34f

Please sign in to comment.