Use reporter in scenarios to send email notifications

Sarthak
Sarthak Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 15 ✭✭✭

Hi,

I have made a setup of scenaios using python api to send emails based on a dataset to various recipients. My concern is that with tme the number of recipients will increase, so is there a possibility that the process may fail in between? The set up includes a base dataset, python script to set the recipient, subject and email body (all of this changes with each recipient). As of now this is working fine, but the process fails after sometime showing an error of Dataiku exception for run and wait. What could be the best way here? Also, I want to know if we can have a delivery report too so that we get to know that the email has been successfully received by the recipient.

Best Answer

Answers

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,215 Dataiker

    Hi @s_dravid
    ,
    You may be able to use sendmail plugin for this case as well:
    - https://www.dataiku.com/product/plugins/sendmail/

    But without knowing what the current scenario looks and the logs for the failure it's hard to advise. I would suggest you open a support ticket with the scenario diagnostics of the failing scenario.

    Thanks,

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,987 Neuron

    Can you post the code snippet of the code that geenrates the failure?

  • Sarthak
    Sarthak Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 15 ✭✭✭

    Hi

    So, I am using below function and calling it for the recipients.

    def emails(mail_body,subject,email):

    scenario_def.raw_reporters[0]['messaging']['configuration']['recipient'] = email
    scenario_def.raw_reporters[0]['messaging']['configuration']['subject'] = subject
    scenario_def.raw_reporters[0]['messaging']['configuration']['message'] = mail_body

    scenario_def.save()
    trigger=scenario.run_and_wait()

    return 'success'

    This runs fine for sometime like sending emails for few people and then it fails like for example on the 10th recipient. The error is displayed as :

    "in wait_for_scenario_run raise Dataiku exception("Scenario run has been cancelled")"

    Also, I would like to know if there is a way to access the plugin recipe for emails through python api.

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,987 Neuron

    First of all you need to find out exactly why the scenario is failing. Please check the scenario logs. Secondly why do you need to use scenario.run_and_wait()? It will be better to run them asynchronously like this:

    https://developer.dataiku.com/latest/concepts-and-examples/scenarios.html#variant-2-run-then-poll-while-doing-other-stuff

    Finally check that your SMTP server does not throttle clients sending too many emails as this could prevent them from going out.

  • Sarthak
    Sarthak Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 15 ✭✭✭

    HI @Turribeach

    The sample code helped here. I modified it as per my need and it is working much faster than using another dummy scenario for using the reporter section. Thanks for your help.

    Regards

    Sarthak

Setup Info
    Tags
      Help me…