CREATE OR REPLACE function post_to_slack(channel varchar ,message varchar)
    RETURNS variant
    LANGUAGE python
    RUNTIME_VERSION = 3.8
    HANDLER = 'main'
    EXTERNAL_ACCESS_INTEGRATIONS = (slack_apis_access)
    PACKAGES = ('requests')
    SECRETS = ('cred' = slack_token)
    AS
    $$
    import _snowflake
    import requests
    import json
    def main(p_channel ,p_message):
        api_key = _snowflake.get_generic_secret_string('cred')
        url = 'https://slack.com/api/chat.postMessage'
        v_headers = {"Authorization": "Bearer "+ api_key}
        v_data_json = {
        'channel': p_channel
        ,'text': p_message
        }
        response = requests.post(url ,headers=v_headers ,json = v_data_json)
        return response.json()
    $$;