npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dingtalk-stream-sdk-nodejs

v2.0.4

Published

Nodejs SDK for DingTalk Stream Mode API, Compared with the webhook mode, it is easier to access the DingTalk

Downloads

13

Readme

dingtalk-stream-sdk-nodejs

Nodejs SDK for DingTalk Stream Mode API, Compared with the webhook mode, it is easier to access the DingTalk chatbot 钉钉支持 Stream 模式接入事件推送、机器人收消息以及卡片回调,该 SDK 实现了 Stream 模式。相比 Webhook 模式,Stream 模式可以更简单的接入各类事件和回调。

快速开始

准备工作

  • Nodejs 开发环境,https://midwayjs.org/docs/how_to_install_nodejs
  • 需要Node version >= 18.17.1
  • 钉钉开发者账号,具备创建企业内部应用的权限,详见成为钉钉开发者

快速开始指南

1、创建企业内部应用

进入钉钉开发者后台,创建企业内部应用,获取ClientID(即 AppKey)和ClientSecret( 即AppSecret)。

发布应用:在开发者后台左侧导航中,点击“版本管理与发布”,点击“确认发布”,并在接下来的可见范围设置中,选择“全部员工”,或者按需选择部分员工。

2、Stream 模式的机器人(可选)

如果不需要使用机器人功能的话,可以不用创建。

在应用管理的左侧导航中,选择“消息推送”,打开机器人能力,设置机器人基本信息。

注意:消息接收模式中,选择 “Stream 模式”

Stream 模式

点击“点击调试”按钮,可以创建测试群进行测试。

3、使用demo项目测试,启动服务:

a、获取demo项目

 git clone [email protected]:open-dingtalk/dingtalk-stream-sdk-nodejs.git

b、在example/config.json里配置应用信息。

c、启动测试case

cd dingtalk-stream-sdk-nodejs
yarn
npm run build
npm start

4、在项目中引用sdk,安装 dingtalk-stream-sdk-nodejs

npm i dingtalk-stream-sdk-nodejs

代码中使用

const DWClient = require("dingtalk-stream-sdk-nodejs");
const config = require("./config.json");

const client = new DWClient({
  clientId: config.clientId,
  clientSecret: config.clientSecret,
});
client.registerCallbackListener('/v1.0/im/bot/messages/get', async (res) => {
    // 注册机器人回调事件
    console.log("收到消息");
    const {messageId} = res.headers;
    const { text, senderStaffId, sessionWebhook } = JSON.parse(res.data);
  })
  .connect();

事件订阅切换到 Stream 模式(可选)

进入钉钉开发者后台,选择企业内部应用,在应用管理的左侧导航中,选择“事件与回调”。 “订阅管理”中,“推送方式”选项中,选择 “Stream 模式”,并保存

技术支持

点击链接,加入Stream模式共创群交流