Created
January 30, 2024 23:50
-
-
Save sendbird-community/5f0a26a123128aa5c4b067f2fb3929a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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