Skip to content
XianSen Zheng edited this page Dec 23, 2023 · 3 revisions

Welcome to the 钉钉对话机器人 wiki!

📦 安装

要安装 SDK,请运行以下命令:

# With NPM
$ npm i -S @zhengxs/wechaty-puppet-dingtalk

# With YARN
$ yarn add @zhengxs/wechaty-puppet-dingtalk

# With PNPM
$ pnpm add @zhengxs/wechaty-puppet-dingtalk

👋 使用

创建一个 钉钉应用,并运行以下代码:

import { PuppetDingTalk } from '@zhengxs/wechaty-puppet-dingtalk';
import { WechatyBuilder } from 'wechaty';

const puppet = new PuppetDingTalk({
  clientId: process.env.DINGTALK_CLIENT_ID,
  clientSecret: process.env.DINGTALK_CLIENT_SECRET,
})

const bot = WechatyBuilder.build({
  puppet,
});

bot.on('message', async msg => {
  log.info('StarterBot', msg.toString());

  if (msg.text() === 'ding') {
    await msg.say('dong');
  }
});

bot.start();
Clone this wiki locally