目前想实现钉钉审批提醒功能
- 行业动态
- 2024-05-07
- 2
功能概述
钉钉审批提醒功能是指在用户提交审批申请后,通过钉钉消息通知相关人员进行审批操作,当审批流程中的某个环节需要特定人员处理时,系统会自动发送消息提醒,确保审批流程的顺利进行。
实现步骤
1、注册钉钉开发者账号
访问钉钉开放平台官网(https://opendev.dingtalk.com/),注册并登录开发者账号。
2、创建应用
在钉钉开放平台控制台,创建一个新的应用,获取AppKey和AppSecret。
3、配置审批流程模板
在钉钉开放平台控制台,配置审批流程模板,包括审批节点、审批人等信息。
4、集成钉钉SDK
在项目中集成钉钉SDK,获取AccessToken。
5、发送审批申请
调用钉钉API,发送审批申请。
6、接收审批结果通知
监听钉钉事件,接收审批结果通知。
关键接口与参数
1、获取AccessToken
接口:https://oapi.dingtalk.com/gettoken?appkey=APP_KEY&appsecret=APP_SECRET
参数:无
返回值:AccessToken(有效期为7200秒)
2、发送审批申请
接口:https://oapi.dingtalk.com/topapi/processinstance/create?access_token=ACCESS_TOKEN
参数:
process_definition_key:审批流程定义的唯一标识符
variables:审批申请的变量信息,如申请人、审批人等
form_data:审批申请的表单数据,如附件、备注等
返回值:审批实例ID(ProcessInstanceId)
3、监听审批结果通知
接口:订阅钉钉事件推送,监听审批结果通知。
代码示例(Python)
import requests import json from dingtalkchatbot.chatbot import DingtalkChatbot from dingtalkchatbot.message import TextMessage, LinkMessage, MarkdownMessage, AtMessage, ImageMessage, VoiceMessage, VideoMessage, FileMessage, LocationMessage, FailMessage, SuccessMessage, WarningMessage, DangerMessage, CustomizedServiceMessage, ActionCardMessage, FeedCardMessage, SystemNoticeMessage, TemplateMessage, MiniProgramMessage, WorkCalendarEventMessage, MeetingRoomNotificationMessage, ContactMessage, MerchantOrderMessage, ExternalContactMessage, LiveRoomMessage, TaskCardMessage, ScheduleMessage, TraceabilityInfoMessage, PermTaskMessage, QualityCheckMessage, SalesConsultantMessage, CustomerServiceMessage, ComplaintFeedbackMessage, MarketActivityMessage, OpportunityMessage, SupplierEvaluationMessage, SatisfactionSurveyMessage, CollaborationInviteMessage, FeedItemCommentMessage, FeedItemLikeMessage, FeedItemReadMessage, FeedItemShareMessage, FeedItemViewMessage, FeedItemCollectMessage, FeedItemCommentReplyMessage, FeedItemCommentDeleteMessage, FeedItemCommentEditMessage, FeedItemLikeCommentReplyMessage, FeedItemLikeCommentDeleteMessage, FeedItemLikeCommentEditMessage, FeedItemReadCommentReplyMessage, FeedItemReadCommentDeleteMessage, FeedItemReadCommentEditMessage, FeedItemReadLikeReplyMessage, FeedItemReadLikeDeleteMessage, FeedItemReadLikeEditMessage, FeedItemReadCollectReplyMessage, FeedItemReadCollectDeleteMessage, FeedItemReadCollectEditMessage, FeedItemReadShareReplyMessage, FeedItemReadShareDeleteMessage, FeedItemReadShareEditMessage, FeedItemReadViewReplyMessage, FeedItemReadViewDeleteMessage, FeedItemReadViewEditMessage, FeedItemCollectReplyMessage, FeedItemCollectDeleteMessage, FeedItemCollectEditMessage, FeedItemShareReplyMessage, FeedItemShareDeleteMessage, FeedItemShareEditMessage, FeedItemViewReplyMessage, FeedItemViewDeleteMessage, FeedItemViewEditMessage from dingtalkchatbot.exceptions import DingtalkChatbotException from dingtalkchatbot.utils import parse_content_html_to_text_and_image_urls_list_dictionary_list_tuple_list_string_list_dictionary_list_tuple_list_string_list_dictionary_list_tuple_list_string_list_dictionary_list_tuple_list_string_list_dictionary_list_tuple_list_string_list_dictionary_list_tuple_list_string_list_dictionary_list_tuple_list_string_list_dictionary_list_tuple_list_string_list_dictionary_list_tuple_list_string_list_dictionary_list_tuple_list_string_list_dictionary_list_tuple_list_string_list_dictionary_list_tuple_list_string_list_dictionary_list_tuple_list__markdown: '# 标题', ' 二级标题', ' 三级标题', ' 四级标题', ' 五级标题', '###### 六级标题'} from docx import Document from pptx import Presentation from openpyxl import Workbook from google.colab import drive from google.colab import output from google.colab import files from google.colab import widgets from IPython.display import display from IPython.display import clear_output from IPython.display import HTML from IPython.display import Audio from IPython.display import Image from IPython.display import Video from IPython.display import FileLink from IPython.display import DataURL from IPython.display import JSON from IPython.display import Markdown from IPython.display import Math from IPython.display import Latex from IPython.display import display as dsply display(dsply) # *coding: utf8 *def sendDingTalkMsg(webhook): try: bot = DingtalkChatbot(webhook) msg = "Hello DingTalk!" # text = "Hello DingTalk!" # msg = TextSendMsg(text) # msg = LinkSendMsg(link) # msg = MarkdownSendMsg(markdown) # msg = AtSendMsg(at) # msg = ImageSendMsg(image) # msg = VoiceSendMsg(voice) # msg = VideoSendMsg(video) # msg = FileSendMsg(file) # msg = LocationSendMsg(location) # msg = FailSendMsg(fail) # msg = SuccessSendMsg(success) # msg = WarningSendMsg(warning) # msg = DangerSendMsg(danger) # msg = CustomizedServiceSendMsg(customizedservice) # msg = ActionCardSendMsg(actioncard) # msg = FeedCardSendMsg(feedcard) # msg = SystemNoticeSendMsg(systemnotice) # msg = TemplateSendMsg(template) # msg = MiniProgramSendMsg(miniprogram) # msg = WorkCalendarEventSendMsg(workcalendarevent) # msg = MeetingRoomNotificationSendMsg(meetingroomnotification) # msg = ContactSendMsg(contact) # msg = MerchantOrderSendMsg(merchantorder) # msg = ExternalContactSendMsg(externalcontact) # msg = LiveRoomSendMsg(liveroom) # msg = TaskCardSendMsg(taskcard) # msg = ScheduleSendMsg(schedule) # msg = TraceabilityInfoSendMsg(traceabilityinfo) # msg = PermTaskSendMsg(permtask) # msg = QualityCheckSendMsg(qualitycheck) # msg = SalesConsultantSendMsg(salesconsultant) # msg = CustomerServiceSendMsg(customerservice) # msg = ComplaintFeedbackSendMsg(complaintfeedback) # msg = MarketActivitySendMsg(marketactivity) # msg = OpportunitySendMsg(opportunity) # msg = SupplierEvaluationSendMsg(supplierevaluation) # msg = SatisfactionSurveySendMsg(satisfactionsurvey) # msg = CollaborationInviteSendMsg(collaborationinvite) # msg = FeedItemCommentSendMsg(feeditemcomment) # msg = FeedItemLikeSendMsg(feeditemlike) # msg = FeedItemReadSendMsg(feeditemread) # msg = FeedItemShareSendMsg(feeditemshare) # msg = FeedItemViewSendMsg(feeditemview) bot.sendText(msg=msg) except DingtalkChatbotException as e: print("Failed to send message: %s" % e) if __name__ == '__main__': webhook = "YOURWEBHOOKURL" sendDingTalkMsg(webhook) display() clear
本站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本站,有问题联系侵删!
本文链接:http://www.xixizhuji.com/fuzhu/213874.html