node.jsapiasana-api

notifications in asana using nodejs asana module


I am trying to put post notifications to asana from a developed application for deployment and code issues. I am using nodejs module 'asana' for that but I could not find the proper method to do that. Can you please help me post notifications or comments in asana to achieve that. Creating a task and adding comments to that task through the application on different events like deployment, onError, etc will work but I could not get the proper documentation to do that!


Solution

  • Asana does not have ant complete api support for conversations https://forum.asana.com/t/creating-team-project-conversations-from-api/1184

    The only way to put conversations on asana using node module support for asana or in similar language:

    
    
         // asana-notifications.js
        const asana = require('asana')
        const logger = require('your-logger')
        module.exports = {
         sendAsanaNotification: async (notification) => {
           try {
             var personalAccessToken = 'your-asana-token'
             var client = asana.Client.create().useAccessToken(personalAccessToken)
             return await client.tasks.addComment('your-task-id', { text: Date() + notification })
           } catch (error) {
             logger.error({
               details: error.message || error,
               errorStack: error,
               message: 'error sending asana notification'
             })
           }
         }
        }
    
        // file in which you want to use it
        const notifications = require('asana-notificaitons')
        asana.sendAsanaNotification(JSON.stringify('your notification'))
        }
    
    
    

    This is the workaround that I have right now. I am using different tasks to put different notifications.