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

claude-api-slack

v1.0.28

Published

slack Authentication Library for ClaudeAI.

Downloads

9

Readme

ClaudeAI for Node.js

Slack Conversation Library for ClaudeAI.

Usage

import cloud from '@lafjs/cloud'

const token = 'xoxp' // slack user token
const bot = 'U05' // claude appid
const chatId = "chat-7890" // 房间名
let text = '讲个故事'

export async function main(ctx: FunctionContext) {
  const { Authenticator } = await import('claude-api-slack')
  // 相当于 ChatGPT 的新建一个回话的 回话 ID,为固定值
  const conversationId = cloud.query.conversationId
  // 通过缓存保存客户端,可以避免每次提问都是在新回话
  let claudeClient = await cloud.shared.get('claudeClient')
  if (!claudeClient) {
    claudeClient = new Authenticator(token, bot)
    await cloud.shared.set('claudeClient', claudeClient)
  }
  // 创建频道并返回房间 ID:channel,创建完房间 ID 是不会变的
  const channel = await claudeClient.newChannel(chatId)
  // 开始第一次提问
  let result = await claudeClient.sendMessage({
    text,
    channel,
    conversationId: 'ed3f4d9f-8d59-482e-8e1d-65d33ddcefb6',
    onMessage: (originalMessage) => {
      // 流式加载
      // console.log(originalMessage)
    }
  })
  console.log('==============1\n', result)
  // 开始第二次提问
  text = '接着讲,接下来进入修仙情节'
  result = await claudeClient.sendMessage({
    text, channel,
    conversationId: result.conversationId,
    onMessage: (originalMessage) => {
      console.log(originalMessage)
    }
  })
  // return { data: 'hi, laf' }
}

授权以及获取 user-token

网页 (登录) 后,进入 api 配置页面 (点我跳转)。

〉》点击【Create an app】

​ 〉》主页看见 Your Apps 并弹出窗口【Create an app】 〉》点击【From scratch】

​ 〉》填写 app 名称以及选择工作空间(例:name: Bot, workspace: chat) 〉》点击【Create App】

​ 〉》点击左侧边栏上的【OAuth & Permissions】 〉》下拉至【Scopes】卡片,在【User Token Scopes】项下添加权限,如下:

​ channels:history, channels:read, channels:write, groups:history, groups:read, groups:write,

​ chat:write, im:history, im:write, mpim:history, mpim:write

​ 〉》回到顶部【OAuth Tokens for Your Workspace】栏,点击【Install to Workspace】,然后确认授权即可

至此,获得拥有一定权限的 user-token

获取 claude appid

Credits Thank you to:

  • https://github.com/ikechan8370/chatgpt-plugin original NodeJS implementation