Skip to content

Commit

Permalink
add various DX enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
valgaze committed May 21, 2024
1 parent ed6a81f commit 3d630e4
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ npm install speedybot

## SpeedyBot basics

You can get a bot up and running fast by grabbing one of the batteries-included samples at **[https://speedybot.js.org/examples](https://speedybot.js.org/examples/)** and see how SpeedyBot has you covered for crafting bots that can do it all-- **[securely integrate w/ LLMs + content management systems](https://speedybot.js.org/examples/voiceflow/README)**, **[process file-uploads](https://speedybot.js.org/patterns.md#handle-file-uploads)**, **[segment content based on user data + behavior](https://speedybot.js.org/patterns.md#restrict-emails)**, create + manage **[SpeedyCards](https://speedybot.js.org/speedycard)**, **[ask for a user's location in a privacy-respecting way](https://speedybot.js.org/examples/location/README)** and lots more.
You can get a bot up and running fast by grabbing one of the batteries-included samples at **[https://speedybot.js.org/examples](https://speedybot.js.org/examples/)** and see how SpeedyBot has you covered for crafting bots that can do it all-- **[securely integrate w/ LLMs + content management systems](https://speedybot.js.org/examples/voiceflow/README)**, **[process file-uploads](https://speedybot.js.org/patterns#handle-file-uploads)**, **[segment content based on user data + behavior](https://speedybot.js.org/patterns#restrict-emails)**, create + manage **[SpeedyCards](https://speedybot.js.org/speedycard)**, **[ask for a user's location in a privacy-respecting way](https://speedybot.js.org/examples/location/README)** and lots more.

## The basics

Expand Down
7 changes: 2 additions & 5 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default defineConfig({
title: "SpeedyBot",
description: "Rich conversation agents, the speedy and easy way",
themeConfig: {
logo: "./..//sb_logo.svg",
logo: "./../sb_logo.svg",
footer: {
message: `<a href="https://github.com/valgaze/speedybot/blob/v2/LICENSE" target="_blank">MIT License</a> ${new Date().getFullYear()}`, // this'll be statically updated everytime redeploy
},
Expand Down Expand Up @@ -83,14 +83,11 @@ export default defineConfig({
},
{
text: "Contributing",
link: "https://github.com/valgaze/speedybot/blob/main/CONTRIBUTING.md",
link: "https://github.com/valgaze/speedybot/blob/v2/contributing.md#contributing",
},
],
},

// { text: "🏡 Home", link: "/" },
],

sidebar: [
{
text: "🤖 Bot Utils ",
Expand Down
25 changes: 24 additions & 1 deletion docs/patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ Bot.exact("$clear", async ($) => {
return $.end;
});

// identify words from a list
// identify words from a list (case-insensitive)
Bot.contains(["bingo", "bongo"], async ($) => {
await $.send(
`You entered text that contained the word bingo/bongo somewhere`
Expand Down Expand Up @@ -330,6 +330,29 @@ Bot.addStep(async ($) => {
});
```

## List Rooms

Retrieve a full list of rooms associated with a `BOT_TOKEN` using `Bot.getAllRooms` or `Bot.getRecentRooms`

This can be be a long-running operation-- `Bot.getAllRooms` captures all rooms by exhaustively checking all pages [pages](https://developer.webex.com/docs/basics#pagination)

```ts
import { SpeedyBot } from "speedybot";

const Bot = new SpeedyBot();
Bot.setToken("BOT_TOKEN");

// List the last 100 recent rooms
const recentRooms = await Bot.getRecentRooms();

// List ALL rooms associated with a BOT_TOKEN
// type: 'direct' | 'group' (default both)
// sortBy: "id" | "lastactivity" | "created";
const allRooms = await Bot.getAllRooms({ type: "group" });

console.log(allRooms.map((room) => room.title));
```

## Handle "chips"

"Chips" in SpeedyBot let users enter text by tapping buttons. Your SpeedyBot will respond as if the user typed the message dispatched in each tap of a chip. This is one of SpeedyBot's most useful but underrated features
Expand Down
48 changes: 22 additions & 26 deletions docs/sb_logo.svg → docs/public/sb_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/llm-stream/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const announceExit = (name?: string) => {
}
console.log(
`
${name ? name : "Your bot"} is now "off"
${name && typeof name === "string" ? name : "Your bot"} is now "off"
You can turn your bot back on by entering the following commands:
Expand Down
1 change: 1 addition & 0 deletions examples/llm-stream/util/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { config } from "dotenv";
import { resolve } from "path";
import { announceExit } from "./index";
process.on("exit", announceExit);
process.on("SIGINT", process.exit.bind(null, 0));

config({ path: resolve(__dirname, "..", ".env") });

Expand Down
2 changes: 1 addition & 1 deletion examples/speedybot-starter/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const announceExit = (name?: string) => {
}
console.log(
`
${name ? name : "Your bot"} is now "off"
${name && typeof name === "string" ? name : "Your bot"} is now "off"
You can turn your bot back on by entering the following commands:
Expand Down
2 changes: 1 addition & 1 deletion examples/speedybot-starter/util/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { config } from "dotenv";
import { resolve } from "path";
import { announceExit } from "./index";
process.on("exit", announceExit);

process.on("SIGINT", process.exit.bind(null, 0));
config({ path: resolve(__dirname, "..", ".env") });

import { SpeedySockets } from "./websockets";
Expand Down
2 changes: 1 addition & 1 deletion examples/voiceflow-kb/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const announceExit = (name?: string) => {
}
console.log(
`
${name ? name : "Your bot"} is now "off"
${name && typeof name === "string" ? name : "Your bot"} is now "off"
You can turn your bot back on by entering the following commands:
Expand Down
2 changes: 2 additions & 0 deletions examples/voiceflow-kb/util/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { config } from "dotenv";
import { resolve } from "path";
import { announceExit } from "./index";
process.on("exit", announceExit);
process.on("SIGINT", process.exit.bind(null, 0));

declare global {
namespace NodeJS {
interface ProcessEnv {
Expand Down
2 changes: 1 addition & 1 deletion examples/voiceflow/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const announceExit = (name?: string) => {
}
console.log(
`
${name ? name : "Your bot"} is now "off"
${name && typeof name === "string" ? name : "Your bot"} is now "off"
You can turn your bot back on by entering the following commands:
Expand Down
2 changes: 2 additions & 0 deletions examples/voiceflow/util/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { config } from "dotenv";
import { resolve } from "path";
import { announceExit } from "./index";
process.on("exit", announceExit);
process.on("SIGINT", process.exit.bind(null, 0));

declare global {
namespace NodeJS {
interface ProcessEnv {
Expand Down

0 comments on commit 3d630e4

Please sign in to comment.