Message Send

Introduction #

SmartPip supports sending email or WeCom (Enterprise WeChat) notifications within DAG tasks, supporting both fixed content and dynamic data. This is suitable for result notifications after task completion.

Notification Methods #

Method Driver Use Case
Email #send_mail Formal reports, detailed data
WeCom #diy + dataset Real-time alerts, short notifications

Usage #

Fixed Content #

msg = ['Report refresh succeeded', '<h1>Refresh Successful!!</h1>']
maillist = 'xxx@smartchart.cn'

#send_mail reportmail msg maillist

Dynamic Data #

maillist = 'xxx@smartchart.cn,abc@xxx.cn'
def fun_msg():
    result = get_dataset(123)['data']
    msg = f'<h3>Dear Leader:</h3><p style="text-indent:20px">Current Sales: {result[1][0]}</p>'
    title = 'Sales Monitor'
    return title, msg

#send_mail reportmail fun_msg maillist

Send WeCom Message #

  • Create a WeCom data source in SmartChart
  • Create a dataset using qiweiMsg data source, fill per WeCom message docs, note the dataset ID (e.g., 12)
{
   "touser" : "1359xxxxx",
   "msgtype" : "text",
   "agentid" : xxxxxxx,
   "text" : {
       "content" : "$msg"
   },
   "safe": 0
}
  • Use a custom task in DAG for WeCom sending:
def notice_content():
    return get_dataset(12, param={'msg':'hello world'})

#diy qiwei_notice  notice_content