Email Notification
Hi,
I just want to check if we could sent notifications to any email id from DSS flows while it is running.
Thanks
Best Answer
-
you can add attachments with an `attachments` field/parameter. The exact structure of an attachment definition depends on the type of attachment, which you can see by creating a reporter in your scenario's settings, adding attachments in it, and checking the changes in the History tab. For example to attach a dataset named 'data' as csv.gz:
from dataiku.core.message_sender import MessageSender s = MessageSender(channel_id='the_channel_id', type='mail-scenario', configuration={}) attachment = { "type": "DATASET", "params": { "exportParams": { "selection": { "samplingMethod": "FULL" }, "format": { "type": "csv", "params": { "style": "excel", "charset": "utf8", "separator": ",", "quoteChar": "\"", "escapeChar": "\\", "parseHeaderRow": True, "compress": "gz" } } }, "attachedDataset": "data" } } s.send(message='the info', subject='the title', recipient='to whom', attachments=[attachment])
Answers
-
Hi,
you can send messages during a scenario run with the "Send message" step. If you need to send messages from within a job (ie you can't simply make a scenario to start jobs and send messages between jobs), and the job is a Python recipe, then you can use
from dataiku.core.message_sender import MessageSender s = MessageSender(channel_id='chan_id', type='mail-scenario', configuration={}) s.send(message='the info', subject='the title', recipient='...')
where chan_id is defined in Administration > Setttings > Notifications & Integrations
-
sj0071992 Partner, Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Dataiku DSS Developer, Neuron 2022, Neuron 2023 Posts: 131 Neuron
Thanks for the reply.
could you please give some clarity on
1. channel_id
2. type
3. configuration
4. recipient
It would be great if there is some link to follow
-
go to Administration > Settings > Notifications & Integrations and create a 'Mail (SMTP)' messaging channel at the bottom. The Id you give here is the channel_id
type is a fixed value.
configuration is a dict in which you can pass 'subject', 'recipient' and 'sendAsHTML' (a boolean). These values can also be passed as kwargs to send()
-
sj0071992 Partner, Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Dataiku DSS Developer, Neuron 2022, Neuron 2023 Posts: 131 Neuron
Thanks once again.
One question where we have to define the sender?
-
sj0071992 Partner, Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Dataiku DSS Developer, Neuron 2022, Neuron 2023 Posts: 131 Neuron
Also, how can i send the data frame from Messagesender
-
sj0071992 Partner, Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Dataiku DSS Developer, Neuron 2022, Neuron 2023 Posts: 131 Neuron
Also, how to add multiple recipient?
-
about the sender: you can pass it in configuration or send(), as a sender field/parameter. But it's cleaner to set it on the message channel in Administratoition > Settings > Notificatoions & Integrations
Multiple recipients are passed as comma-separated values.
The question about dataframes is unclear: are you intending to attach a dataset to the message?
-
sj0071992 Partner, Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Dataiku DSS Developer, Neuron 2022, Neuron 2023 Posts: 131 Neuron
Thanks for the clarification.
Yes i want to attached a dataframe as csv
-
sj0071992 Partner, Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Dataiku DSS Developer, Neuron 2022, Neuron 2023 Posts: 131 Neuron
I Just tried this, I am able to send the JSON in the message body of the email but still not able to send the attachment. I am using the below format,
attachment = {
"type": "DATASET",
"params": {
"exportParams": {
"selection": {
"samplingMethod": "FULL"
},
"format": {
"type": "csv",
"params": {
"style": "excel",
"charset": "utf8",
"separator": ",",
"quoteChar": "\"",
"escapeChar": "\\",
"dateSerializationFormat": "ISO",
"arrayMapFormat": "json"
"parseHeaderRow": True,
"compress": ""
}
}
},
"attachedDataset": "data"
}
} -
by JSON, do you mean "json version of a dataframe"? Is it a pandas dataframe you're building in the python code? If so, you should have it written either to some dataset and attach the dataset with the same example as before, or dump the csv to a managed folder, and use a file-from-a-folder attachment
-
sj0071992 Partner, Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Dataiku DSS Developer, Neuron 2022, Neuron 2023 Posts: 131 Neuron
Let it be. Thanks for your help. It solves 90% of my problem. Rest I need to configure.