Discord

Overview

Our Discord integration allows customers to interact with our AI model using the popular Discord platform. This integration enables users to ask questions, provide feedback, and receive responses directly within Discord.

Features

  • Conversational Interface: Users can interact with our AI model using natural language, asking questions and receiving responses in a conversational format.

  • Markdown Support: Our integration supports Markdown formatting, allowing users to receive richly formatted responses with bold, italic, and other text styles.

  • Error Handling: Our integration includes robust error handling, ensuring that users receive a response even if there's an issue with the API request or response.

  • Fallback to Plain Text: If Markdown parsing fails, our integration falls back to sending a plain text response, ensuring that users always receive a response.

  • Sentiment and Feedback Analysis: Our integration can also perform sentiment and feedback analysis on user input, providing valuable insights into user opinions and preferences.

How it Works

  1. Users interact with our Discord bot by sending a message or question.

  2. Our integration sends the user's input to our AI model for processing.

  3. Our AI model responds with a JSON object containing the response text.

  4. Our integration parses the response text as Markdown and sends it to the user as a Discord message.

  5. If Markdown parsing fails, our integration falls back to sending a plain text response.

Usage Examples

To trigger our Discord integration, users can send a message to our bot with the following format:

Hey botname <question or message>

For example:

Hey botname What is the weather like today?

This will send a request to our AI model, which will respond with a JSON object containing the response text. Our integration will then parse the response text as Markdown and send it to the user as a Discord message.

Code Snippets

Here's an example of how to use our Discord integration in a Discord server:

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('message', (message) => {
  if (message.content.startsWith('Hey botname')) {
    const question = message.content.replace('!finery', '').trim();
    // Send request to our AI model
    axios.post('OUR_API_URL', {
      question: question,
    })
   .then((response) => {
      const responseText = response.data.text;
      // Parse response text as Markdown
      const parsedResponse = parseMarkdown(responseText);
      // Send response to user
      message.channel.send(parsedResponse);
    })
   .catch((error) => {
      console.error(error);
      // Send error message to user
      message.channel.send('Error:'+ error.message);
    });
  }
});

client.login('OUR_BOT_TOKEN');

This code snippet uses the discord.js library to create a Discord bot instance, and listens for messages starting with the Hey botname command. When a message is received, it sends a request to our AI model with the user's question, and then parses the response text as Markdown before sending it back to the user.

Benefits

  • Convenient: Users can interact with our AI model directly within Discord, without needing to switch to a separate interface.

  • Flexible: Our integration supports a wide range of use cases, from simple Q&A to more complex conversations.

  • Robust: Our error handling and fallback mechanisms ensure that users always receive a response, even if there's an issue with the API request or response.

  • Valuable Insights: Our sentiment and feedback analysis capabilities provide valuable insights into user opinions and preferences, allowing businesses to make data-driven decisions.

Last updated