Hi everyone i was trying to send notifications usi...
# ask-community
s
Hi everyone i was trying to send notifications using slack webhook block in the message i am using
Copy code
slack_webhook_block.notify(
        (
            f"Your job {flow_run.name} entered {state.name} "
            f"with message:\n\n"
            f"See {PREFECT_API_URL.value()}/flow-runs/"
            f"flow-run/{flow_run.id}|the flow run in the UI>\n\n"
            f"Tags: {flow_run.tags}\n\n"
            f"Scheduled start: {flow_run.expected_start_time}"
        )
but the url returned is not working do i have to add something else too in this?
The code i used is directly from prefect docs
Copy code
from prefect import flow
from prefect.blocks.notifications import SlackWebhook
from prefect.settings import PREFECT_API_URL

def notify_slack(flow, flow_run, state):
    slack_webhook_block = SlackWebhook.load("de-slack-test")

    slack_webhook_block.notify(
        (
            f"Your job {flow_run.name} entered {state.name} "
            f"with message:\n\n"
            f"See {PREFECT_API_URL.value()}/flow-runs/"
            f"flow-run/{flow_run.id}|the flow run in the UI>\n\n"
            f"Tags: {flow_run.tags}\n\n"
            f"Scheduled start: {flow_run.expected_start_time}"
        )
    )

@flow(on_failure=[notify_slack], retries=1)
def failing_flow():
    raise ValueError("oops!")

if __name__ == "__main__":
    failing_flow()
but the url returned doesn’t work in the slack message
@Jamie Zieziula any recommendations here 👆
j
I think its because you’re using the API url and not the UI url
w
What jamie said ^. import PREFECT_UI_URL and use that rather than the API one.