send attachment from dataiku to teams channel.

Options
TheMLEngineer
TheMLEngineer Registered Posts: 25

Looking for options to send attachment from dataiku to teams channel. Anyone setup this before?

Answers

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

    What kind of attachment and why? You could send a dataset but they are limits on how much data you can send.

  • TheMLEngineer
    TheMLEngineer Registered Posts: 25
    Options

    Thanks for quick response. I have good number of users on our platform who are asking for this capability. csv, png, excel, pdf etc. files. My research found I would need to use MS Grapgh API Explorer. That would require more permissions on teams to access teams_id, channel_id etc. Asking around for alternatives.

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

    You can use the MS Graph API but it's much easier to use the built-in scenario reporter functionality. To do that follow the following steps:

    1. In Microsoft Teams navigate to the Teams channel you want to receive notifications from Dataiku. Note this should be a proper Teams Channel rather than a chat conversation or a Meeting chat group. Once you are in the channel click on the 3 dots menu in the top right and then click on the Connections option:

      content.png

    2. On the resulting screen click on the Configure button under Incoming Webhook (to manage existing Webhooks click on Configured under Manage):Screenshot 2024-05-06 224653.png
    3. Now give the Webhook a name and click on the Create button. Optionally you can upload an image as well which will be displayed in Teams when the notification is posted but otherwise you can leave the default image.
    4. Once you click on Create you should see the confirmation screen. Make sure you copy the Webhook URL as this will be needed in Dataiku.
    5. Once you copied the Webhook URL click on the Done button and go to your Dataiku project where you want to send the Teams notification from. Open the Scenario you want to use and go to the Steps tab. Click on the ADD STEP button and under the CODE section select "Execute Python Code". The Script window should open. Paste this code in it:

    import dataikufrom dataiku.scenario import Scenario​# The Scenario object is the main handle from which you initiate stepsscenario = Scenario()​my_dataset_handle = dataiku.Dataset("YOUR DATASET NAME")my_dataset_df = my_dataset_handle.get_dataframe()​my_dataset_html = ""my_dataset_html += "Scenario result: ${outcome}<br>"my_dataset_html += "Scenario URL: ${scenarioRunURL}<br>"my_dataset_html += "<br><br>"my_dataset_html += my_dataset_df.to_html(columns=['COLUMN1', 'COLUMN2', 'COLUMN3', 'COLUMN4'],header=True, index=False, na_rep='', max_rows=20)​message_sender = scenario.get_message_sender(None, "msft-teams-scenario")message_sender.send(message=my_dataset_html, webhookUrl="Insert Teams webhook URL")

    • You need to update the following:

      YOUR DATASET NAME: Set the name of the dataset you wish you send in the notification
      'COLUMN1', 'COLUMN2', 'COLUMN3', 'COLUMN4': Select the names of the columns you wish you send in the notification
      Teams webhook URL: The Webhook URL you got from the previous step
      Adjust the max_rows to your desired max number of rows. Of course this being a Teams notification you can't send large tables or your will get a notification that says “This message is too long to display here. Please visit the external source app to view the message”. In my tests I was able to send a table that had 12,000 characters so there is plenty of room (within reason) to play with.

    With the above code you can send datasets which should be more useful than sending attachments. I don't believe it's possible to send any attachments using this notifications channels functionality. But, as you can see from the above sample, the message can use any valid HTML so if you can store your attachments files somewhere else (like Sharepoint) you can hotlink to them in your Teams message. That's probably a much better solution as it will keep the messages "small" and leave potential heavy attachments for a storage layer than can handle them properly.

  • TheMLEngineer
    TheMLEngineer Registered Posts: 25
    Options

    Thank you @Turribeach
    . I have requested for more team permissions so i can see the connector option. Will let you know how it goes.

  • TheMLEngineer
    TheMLEngineer Registered Posts: 25
    Options

    It worked!! Thank you

  • me2
    me2 Registered Posts: 48 ✭✭✭✭✭
    Options

    We found what works best is sending a notification from Dataiku to MS Teams (via the solution @Turribeach
    gave) and sending an excel to a Sharepoint site (same MS Team but different channel).

    Once in Sharepoint, the teams can link their own Excel files to that file in case they want custom pivot tables. That requires a one-time-hard-to-find-but-easy-to-set-up step.. syncing the users computer with the sharepoint site.

    https://support.microsoft.com/en-us/office/sync-sharepoint-and-teams-files-with-your-computer-6de9ede8-5b6e-4503-80b2-6190f3354a88

    Good luck!

Setup Info
    Tags
      Help me…