句子互動(dòng) | Connect to Wechat: Bot Builder Adapter for Wechat Individual Account

Microsoft Bot Framework v4 adapter for Wechat IndividualAccount

BotBuilder Wechaty Adapter

Source: Time to do it differently, build chatbots with streams

If you are finding the Bot Framework v3 version of this adapter, please goto:

  1. the v3.0 branch, or
  2. NPM botbuilder-wechaty-connecter@3

FEATURES

  • Ready for Microsoft Bot Framework v4
  • no need a registered bot on dev.botframework.com, but require a wechat individual(NOT official!) account.
  • Powered by wechaty
  • Support receiving and sending almost any wechat message types(WIP)

INSTALLATION

npm install botbuilder-wechaty-adapter

Preparation

We assume that, you already have a wechat individual account.

EXAMPLE

An example is located at examples/ directory. Using following command to run it.

git clone git@github.com:huan/botbuilder-wechaty-adapter.git
cd botbuilder-wechaty-adapter
npm install
npm run example

import {
  ActivityTypes,
  TurnContext,
}                 from 'botbuilder'

import { WechatyAdapter } from 'botbuilder-wechaty-adapter'

export class EchoBot {

  public async onTurn (
    turnContext: TurnContext,
  ): Promise<void> {
    console.info('EchoBot', 'onTurn() %s', turnContext)
    if (turnContext.activity.type === ActivityTypes.Message) {
      const text = turnContext.activity.text
      console.info('RECV:', text)
      switch (text.toLowerCase()) {
        case 'quit':
          console.info('Quiting...')
          process.exit(0)
          break

        case 'ding':
          console.info('Replying `dong`...')
          await turnContext.sendActivity('dong')
          console.info('Replied.')
          break

        default:
          console.info('EchoBot', 'onTurn() skip message "%s"', text)
      }
    }
  }

}

const echoBot = new EchoBot()
const adapter = new WechatyAdapter()
adapter.listen(async (turnContext: TurnContext) => {
  await echoBot.onTurn(turnContext)
}).catch(console.error)

console.info('> Wechaty EchoBot is online. I will reply `dong` if you send me `ding`!')
console.info('> Say "quit" to end.\n')

Slides

<iframe src="https://docs.google.com/presentation/d/e/2PACX-1vQuR4VQbUXdS4rsVjTs7FDNwWbhRb1voaXBzMBsza62ukwwbppCN1D5DdxMym5PpcCG2lmub6-EQ0KX/embed?start=false&loop=false&delayms=3000" width="1306" height="763" allowfullscreen="" webkitallowfullscreen="true" mozallowfullscreen="true" frameborder="0" style="box-sizing: border-box; position: absolute; top: 0px; left: 0px; width: 636px; height: 387.75px;"></iframe>

Connect to Wechat: Bot Builder Adapter for Wechat Individual Account

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 11,075評(píng)論 0 23
  • # Awesome Python [![Awesome](https://cdn.rawgit.com/sindr...
    emily_007閱讀 2,333評(píng)論 0 3
  • Awesome Ruby Toolbox Awesome A collection of awesome Ruby...
    debbbbie閱讀 3,085評(píng)論 0 3
  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc閱讀 2,992評(píng)論 0 0
  • 零星小雪開始下了 又大一點(diǎn) 難道這是今年最大的雪嗎 盼啊盼啊,多么希望下一場大雪啊
    微微笑_0464閱讀 266評(píng)論 0 0

友情鏈接更多精彩內(nèi)容