Sending Slack notifications from Scenario script

Solved!
rmnvncnt
Level 3
Sending Slack notifications from Scenario script

Hello,

I'm trying to send custom slack notifications using the scenario Python API, but I could not find documentation on the webhook parameters. Here, "slack_error_staging" is already configured (and working). I'm going for something like this :

sender = scenario.get_message_sender("slack_error_staging")
    
sender.send(
    sender="romain", 
    message="foo",
    mode="incoming_webhook",
    url="https://hooks.slack.com/services/stuff"
)

I don't know what value should be used for the "mode" parameter to elicit the expected behavior. I don't know if "url" is the correct spelling either.

Best,

Romain

1 Solution
rmnvncnt
Level 3
Author

The actual parameters are :

sender.send(
    username="romain",
    message="Test",
    mode="WEBHOOK",
    webhookUrl="https://hooks.slack.com/services/stuff"
)

View solution in original post

8 Replies
rmnvncnt
Level 3
Author
Anyone?
0 Kudos
rmnvncnt
Level 3
Author

The actual parameters are :

sender.send(
    username="romain",
    message="Test",
    mode="WEBHOOK",
    webhookUrl="https://hooks.slack.com/services/stuff"
)
tiborstanko
Level 1

thanks!

0 Kudos
importthepandas

Docs for this method need to be updated/fleshed out -- they are pretty nonexistent. Docstring on the class itself in install is also just a one liner. Hard to tell what we can use unless we back up into other methods being called in source.

0 Kudos
CoreyS
Dataiker Alumni

Hey @importthepandas I think there is some additional documentation on this subject if I am not mistaken (and maybe I am):

Note that Slack uses a specific format for its messages, and leaves html as-is.

I hope this helps!

Looking for more resources to help you use Dataiku effectively and upskill your knowledge? Check out these great resources: Dataiku Academy | Documentation | Knowledge Base

A reply answered your question? Mark as โ€˜Accepted Solutionโ€™ to help others like you!
0 Kudos
bantucaravan
Level 2

I am afraid @CoreyS  you are mistaken. Those docs do not explain how to use the python sdk (`dataiku`) to send a message. `dataiku.scenario.Scenario().get_message_sender()` is not satisfactorily documented and worse `dataiku.scenario.messaging.ScenarioMessageSender.send()` is not documented AT ALL as far as I can see. So I have no idea where the parameter values in the accepted answer are sourced.

0 Kudos
CoreyS
Dataiker Alumni

Hi @bantucaravan thank you for your feedback and sorry that you did not find this particular thread useful. I will surface your feedback internally in terms of document improvement.

Looking for more resources to help you use Dataiku effectively and upskill your knowledge? Check out these great resources: Dataiku Academy | Documentation | Knowledge Base

A reply answered your question? Mark as โ€˜Accepted Solutionโ€™ to help others like you!
0 Kudos
bantucaravan
Level 2

Thank you, from another thread I was shown this documentation which does partially answer the question of what parameters to use with sender.send()

https://doc.dataiku.com/dss/latest/scenarios/custom_scenarios.html#send-custom-reports