This notebook demonstrates how to build a custom financial assistant Discord bot using OpenBB and CAMEL-AI. By integrating real-time financial data and advanced AI-driven interactions, this tutorial showcases an innovative approach to delivering dynamic financial insights. In this notebook, you’ll explore:
- CAMEL-AI: A versatile multi-agent framework that powers the financial assistant with intelligent tool-calling and natural language understanding, ensuring precise and professional responses.
- OpenBB: An open-source platform for advanced financial research, offering tools for analyzing stocks, cryptocurrencies, and market trends through an intuitive API integration.
- Qwen: A large language model developed by Alibaba Cloud, used for generating intelligent and contextually aware responses in the assistant’s interactions.
- Discord Integration: A step-by-step guide to creating and deploying a chatbot in Discord, enabling seamless interaction with users and delivering financial insights in a community setting.

📦 Installation
First, install the CAMEL package with all its dependencies:🔑 Setting Up API Keys
Setting up Qwen API Key
In this tutorial, we will be using Qwen model. Qwen is a large language model developed by Alibaba Cloud. It is trained on a massive dataset of text and code and can generate text, translate languages, write different kinds of creative content, and answer your questions in an informative way. You’ll need to set up your API keys for Qwen. This ensures that the tools can interact with external services securely. If you don’t have a Qwen API key, you can obtain one by following these steps:- Visit the Alibaba Cloud Model Studio Console (https://www.alibabacloud.com/en?_p_lc=1) and follow the on-screen instructions to activate the model services.
- In the upper-right corner of the console, click on your account name and select API-KEY.
- On the API Key management page, click on the Create API Key button to generate a new key.
Setting up OpenBB Personal Access Token (PAT)
OpenBB is an open-source platform designed for advanced investment research, empowering users with tools to analyze financial data, create visualizations, and generate detailed reports. Catering to retail investors, financial analysts, and enthusiasts, OpenBB provides access to functionalities typically available only on expensive institutional platforms. It supports stock data exploration, portfolio analysis, market trend evaluation, and integration with premium APIs, all through an intuitive terminal or command-line interface. CAMEL has integrated an OpenBB toolkit that allows CAMEL agents to access plenty of OpenBB’s powerful functions easily. For more information about the toolkit, please refer to the OpenBBToolkit documentation. To use the toolkit, we would need an OpenBB Personal Access Token (PAT).How to obtain an OpenBB PAT
- Please login to the OpenBB Platform or sign up as prompted if you do not have an account yet.
- In ‘SETTINGS’, go to ‘Personal Access Token’.
- You can now see your OpenBB personal access token (PAT).
Set up Agent Equipped with OpenBB and date tools
In this step, we will define the tools and the system prompt for ourChatAgent
.
Since the LLMs do not intrinsically know the current dates, we need to define a date tool to get the current date.
Below we also set the prompt to pass into the agent for better tool calling and output formatting.
Basic Chatbot Setup
Let’s set up the basic Chatbot with CAMEL Agent equipped with OpenBB and date tools and ask some questions! For example, we can ask: What was the price of Tesla yesterday?Basic Discord Bot Integration
To build a discord bot, a discord bot token is necessary. If you don’t have a bot token, you can obtain one by following these steps:- Go to the Discord Developer Portal: https://discord.com/developers/applications
- Log in with your Discord account, or create an account if you don’t have one
- Click on ‘New Application’ to create a new bot.
- Give your application a name and click ‘Create’.
- Navigate to the ‘Bot’ tab on the left sidebar and click ‘Add Bot’.
- Once the bot is created, you will find a ‘Token’ section. Click ‘Reset Token’ to generate a new token.
- Copy the generated token securely.
- Navigate to the ‘OAuth2’ tab, then to ‘URL Generator’.
- Under ‘Scopes’, select ‘bot’.
- Under ‘Bot Permissions’, select the permissions your bot will need (e.g., ‘Send Messages’, ‘Read Messages’ for our bot use)
- Copy the generated URL and paste it into your browser to invite the bot to your server.
- Navigate to the ‘Bot’ tab
- Under ‘Privileged Gateway Intents’, check ‘Server Members Intent’ and ‘Message Content Intent’.
camel.bots
library. The bot listens for messages in any channel it has access to and provides a response based on the input message.


- 🐫 Creating Your First CAMEL Agent free Colab
- Graph RAG Cookbook free Colab
- 🧑⚖️ Create A Hackathon Judge Committee with Workforce free Colab
- 🔥 3 ways to ingest data from websites with Firecrawl & CAMEL free Colab
- 🦥 Agentic SFT Data Generation with CAMEL and Mistral Models, Fine-Tuned with Unsloth free Colab