Skip to content

Instantly share code, notes, and snippets.

@homanp
Last active October 2, 2023 19:35
Show Gist options
  • Save homanp/a5b8654e7412cd63704abe20ed67e4c8 to your computer and use it in GitHub Desktop.
Save homanp/a5b8654e7412cd63704abe20ed67e4c8 to your computer and use it in GitHub Desktop.
create.js
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const superagentToken = "";
const agentId = "";
const channelId = context.params.event.channel_id;
const authorId = context.params.event.author.id;
const [response] = await Promise.all([
fetch(`https://api.beta.superagent.sh/api/v1/agents/${agentId}/invoke`, {
method: "POST",
headers: {
"content-type": "application/json",
authorization: `Bearer ${superagentToken}`
},
body: JSON.stringify({
enableStreaming: false,
input: context.params.event.content,
sessionId: authorId,
})
}),
lib.discord.channels['@0.3.0'].typing.create({
channel_id: `${context.params.event.channel_id}`,
}),
])
const {data: {output}} = await response.json();
await lib.discord.channels['@0.3.4'].messages.create({
channel_id: `${context.params.event.channel_id}`,
output,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment