Skip to content

Instantly share code, notes, and snippets.

@sendbird-community
Created January 30, 2024 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sendbird-community/5f0a26a123128aa5c4b067f2fb3929a0 to your computer and use it in GitHub Desktop.
Save sendbird-community/5f0a26a123128aa5c4b067f2fb3929a0 to your computer and use it in GitHub Desktop.
const passMessageToSendbirdBot = async (payload) => {
try {
const response = await axios.post(`https://api-${process.env.SENDBIRD_APP_ID}.sendbird.com/v3/bots/YOUR_BOT_ID/ai_chatbot_replies`, {
messages: [
{ role: 'user', content: payload.text }
]
}, {
headers: { 'Api-Token': process.env.SENDBIRD_API_TOKEN, 'Content-Type': 'application/json' },
maxBodyLength: Infinity
});
const message = { response_type: 'in_channel', text: `A: ${response.data.reply_messages[0]}` };
await axios.post(payload.response_url, message);
} catch (error) {
console.error('Error in performFurtherActions:', error);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment