Page cover

Integrations

Integrations

Lab.fun supports seamless integrations with popular platforms and services. Here are some examples:

Slack Integration

Integrate Lab.fun with Slack to enable interactive chatbots directly within your Slack workspace:

const { LabFun } = require('labdotfun-sdk');
const { SlackAdapter } = require('labdotfun-slack');

const bot = new LabFun({
  apiKey: 'your-openai-api-key',
});

const slackAdapter = new SlackAdapter({
  token: 'your-slack-bot-token',
});

bot.use(slackAdapter);

bot.on('message', (userMessage) => {
  const reply = bot.generateResponse(userMessage);
  slackAdapter.sendMessage(reply, userMessage.channel);
});

bot.start();

Discord Integration

Bring Lab.fun to Discord servers for community engagement:

const { LabFun } = require('labdotfun-sdk');
const { DiscordAdapter } = require('labdotfun-discord');

const bot = new LabFun({
  apiKey: 'your-openai-api-key',
});

const discordAdapter = new DiscordAdapter({
  token: 'your-discord-bot-token',
});

bot.use(discordAdapter);

discordAdapter.on('message', (userMessage) => {
  const reply = bot.generateResponse(userMessage.content);
  discordAdapter.sendMessage(reply, userMessage.channel.id);
});

bot.start();

Webhook Integration

Lab.fun supports webhooks for custom integrations with external systems:

const { LabFun } = require('labdotfun-sdk');
const express = require('express');

const app = express();
app.use(express.json());

const bot = new LabFun({
  apiKey: 'your-openai-api-key',
});

app.post('/webhook', (req, res) => {
  const userMessage = req.body.message;
  const reply = bot.generateResponse(userMessage);
  res.json({ reply });
});

app.listen(3000, () => {
  console.log('Webhook server running on port 3000');
});

Last updated