Skip to main content

4 posts tagged with "guide"

View All Tags

· 5 min read

Flows.network is a serverless platform that allows you to build and deploy LLM applications without worrying about infrastructure management. In this guide, we will walk you through the process of building a ChatGPT Discord bot using flows.network, step-by-step. More importantly, you don’t need to master any coding skills.

This bot can

  • Customizable prompts - You can copy and paste any prompt for the bot to respond to. Feel free to get creative!
  • Direct message responses - Have a private conversation with the bot by direct messaging it.
  • Channel message responses - The bot can respond to messages posted in channels, allowing all channel members to interact with it.
  • External service integration - Services like OCR can be integrated to expand the bot's functionality. For example, the bot can process images with OCR.

1. Get a Discord Bot Token

To get started, you need to have a Discord account. And then follow these steps:

You can also refer to How to create a Discord chat bot for more information.

1.1 Create a New Application

  • Visit the Discord Developer Portal and log in with your Discord account.
  • Click on "New Application" and provide a name for your bot.
  • Navigate to the "Bot" tab and click on "Add Bot."

1.2 Obtain Bot Token

  • Go back to the "Bot" tab and click on "Copy" under the "TOKEN" section. Keep this token secure as it will be used to authenticate your bot.
  • Turn on the "PRESENCE INTENT", "SERVER MEMBERS INTENT", and "MESSAGE CONTENT INTENT" settings.

1.3 Add a Bot to Your Application

  • Under the "OAuth2" tab, select the "bot" scope.
  • Scroll down and select the required bot permissions based on your bot's functionality.
  • Copy the generated bot invite URL and invite the bot to your server. You can see your bot is offline.

2. Set up a flows.network Account

Now that you have set up your Discord bot account, let's set up a flows.network account.

  • Visit the flows.network website and sign up for a new account with your GitHub account.

3. Create the Discord ChatGPT Bot on flows.network

All the preparations are ready. Let’s create a Discord ChatGPT bot from a template.

3.1 Load the ChatGPT Discord Bot template

Click here to load the ChatGPT Discord bot template.

Click the purple Install and Authorize our GitHub app to grant flows.network to access your GitHub repo. After that, review the system_prompt. You can copy and paste prompts from here. The text you input here decides what the role of the chatbot.

Then, Click Create and Build to process.

3.2 Configure the Bot

Next, configure the integrations required by this flow template. It’s Discord and ChatGPT API keys.

Copy and paste your Discord token into the red rectangle. Then click the Continue button.

Next, let’s configure the ChatGPT API key.

Click on Connect, and you will be redirected to a new page where you can copy and paste your OpenAI key here.

Close the tab and go back to the flow.network page once you are done. Click on the Deploy button.

4. Test and Interact with the Bot

Once the status of the flow turns ready and running, go back to your Discord server and you can find the bot is online now. DM the bot and the bot will now answer your questions.

Conclusion

By following this step-by-step guide, you have learned how to build a ChatGPT Discord bot on flows.network, without any coding! flows.network provides a serverless platform to simplify the deployment process and allows you to focus on building engaging chat experiences for your Discord community. Have fun experimenting and building conversational experiences with your new bot!

Other templates using Discord

FAQs

Is flows.network a free platform?

flows.network is currently free to use.

Can I integrate other APIs with my flows.network bot?

Yes, flows.network allows you to integrate various SaaS APIs to enhance the functionality of your bot. You can connect to external services, databases, and other APIs as needed. Check out the Hacker-News-ChatGPT-Discord function, which access API for Hacker News.

What kind of customization options are available for the ChatGPT on flows.network?

flows.network provides configuration options: systerm_prompt to customize the behavior of the ChatGPT bot. And the bot's source code is available in the GitHub repo you cloned from the template. You can set the response length, retry times to guide the bot's behavior if you can change the source code.

Can I deploy multiple bots on flows.network?

Of course, you can deploy multiple bots on flows.network.

You can manually create a new flow and import the source code repo for the bot (i.e., the repo you cloned from the template). Then configure the OPENAI and Discord integrations accordingly.

You can have a single flow function repo deployed as the source code for multiple bots. When you update the source code in the repo, and push it to GitHub, it will change the behavior of all the bots.

· 4 min read

Recently, flows.network supports Anthropic's Claude and its newly issued Claude 2 (100k tokens supported). We talked about how to build a Telegram ChatGPT bot. In this guide, I will walk you through the process of building your own Telegram chatbot powered by Claude in just three minutes using flows.network. You won't need to write any code or manage any servers. All you have to do is click a few buttons and provide some information.

With this Claude Telegram chatbot, you can:

  • Customize prompts to prompt Claude based on your needs
  • Chat privately and in a public group
  • Optionally set the maximum token length for your Claude model in the code

Before we start, let’s learn some basic concepts of Claude and the Telegram bot.

What is Claude

Claude is an AI assistant created by Anthropic to be helpful, harmless, and honest. It was designed using a technique called Constitutional AI, which trains language models like Claude through natural conversations. During these conversations, humans provide feedback to reinforce positive behavior and ensure safety and transparency.

By building your own Claude bot on Telegram, you contribute to the development of AI that prioritizes trustworthy and reliable interactions. Your bot's users will experience Claude as a helpful and honest AI partner, designed and trained to uphold those values above all else.

If you're new to Telegram bots, you can refer to our previous article which introduced telegram bot.

Create a Claude Telegram Bot from a Flow Template in Three Steps

The first step is to load the pre-built template for creating a Claude Telegram bot on your browser. Before you click on Create and Build button, you can review the three optional variables like the following image. Here I want to highlight the system_prompt variables. This is for prompting Claude. You can type any prompts here.

The template contains the source code for the bot itself. We will clone the source code to your own GitHub account so that you can modify and customize it later.

Once you have made your customizations, click the Create and Build button, and you will be directed to another page to configure the Claude integration. Next, you need to add your Claude API key. Click on Connect and enter your key.

If you don’t have one, apply here.

Then, you need to add the Telegram token. You can follow this article to get a Telegram token from @botfather. Once you're done, the grey Deploy button will turn purple. Click on the Deploy button in purple to complete the flow.

That's it! Once the function is ready and the flow's status is "running," you can test your own Claude Telegram bot. You can explore different roles for your bot, such as polishing English writing, serving as a writing tutor, or explaining code, by using different prompts.

If you'd like to check out the source code,

Access External Web Service

The bot's flow function can access the web, enabling Telegram to utilize up-to-date information and web services in conjunction with Claude. In simpler terms, you have the ability to incorporate plugin-like functionalities of Claude into your own bot.

For example, you can make HTTPS requests to an external web service to look up the current weather and parse the result from the response JSON data.

fn get_weather(city: &str) -> Result<ApiResult, String> {
let mut writer = Vec::new();
let api_key = std::env::var("API_KEY").unwrap();
let query_str = format!(
"https://api.openweathermap.org/data/2.5/weather?q={city}&units=metric&appid={api_key}"
);

request::get(query_str, &mut writer)
.map_err(|e| e.to_string())
.and_then(|_| {
serde_json::from_slice::<ApiResult>(&writer).map_err(|_| {
"Please check if you've typed the name of your city correctly".to_string()
})
})
}

Combining Claude with the web, your Telegram bot will be just like a ChatGPT Plugin and leverage conversational UI for complex applications. Calling external web services provides more dynamic and real-world functionality. For example, you can call the SendGrid API to send emails based on ChatGPT outputs.

References:

· 5 min read

If you're a hacker who frequents the popular news aggregation site Hacker News, you know how quickly posts can get lost in the shuffle. With hundreds of new stories appearing each day, it can be tough to keep up with the topics that matter most to you. But what if there was a way to be notified anytime a post contained a specific keyword? That's where this article comes in.

I will walk you through how to build a bot to automatically send Slack messages if a Hacker News post contains the keyword you are concerned with on the flows.network platform. You can also extend this Hacker News bot to another SaaS platform that flows.network has integrated, like Notion, Discord, Telegram, Airtable, and so on.

Hacker News Alert

What is Hacker News

Before we start, let’s learn more about Hacker News. If you’re familiar with Hacker News, you can skip the next two sections. Hacker News is a social news website focused on technology and startups. It was created by Paul Graham's investment fund and startup incubator, Y Combinator, originally as a way for Y Combinator founders to share information and news.

Today, Hacker News has evolved into a popular online community for entrepreneurs, tech enthusiasts, and investors to share and discuss news, articles, and information related to technology, startups, and the wider tech industry. The website features a minimalist design that prioritizes original content and discussions over flashy graphics and ads.

Hacker News can be used as a valuable resource for people interested in keeping up with the latest news and trends in the tech industry. By participating in discussions and sharing content on Hacker News, individuals can gain exposure for their own projects, ideas, and businesses, as well as connect with other like-minded individuals who can offer valuable insights and feedback.

Hacker News Alert

Why we need a tool to search and monitor the posts of Hacker News

As an entrepreneur, tech enthusiast, or investor, staying on top of industry news and trends is crucial. However, manually scanning through every Hacker News post each day is time-consuming and impractical. However, with flows.network, it’s possible to build a Hacker News Slack bot to search and monitor keywords that we value. The benefits of the bot are

  • Automatic: It will automatically send you the Hacker News posts via Slack messages at the scheduled time. No need to keep an eye on the Hacker News website.
  • Scheduled and recorded: Schedule a time at your convenience to receive the Hacker News alerts. One of the reasons why we choose Slack is that Slack could help us save the past Hacker News posts.
  • Flexible: You can customize the time you receive the Hacker News post. You also change another SaaS tool like Airtable as a receiver.

How to create a Hacker News Slack bot, taking ChatGPT as an example

Now that we've established the need and benefits for a Hacker News Slack bot. let's take a closer look at how to build your own on flows.network. It's quite easy.

For example, if a post on Hacker News contains ChatGPT, you will receive a message on a Slack channel. This message will include the post’s Hacker News link and the source link of the post.

Make sure you have signed up for an account for flows.network.

  1. Load the Hacker News alert bot template in flows.network. The template contains the source code for the bot itself. We will clone the source code to your own GitHub account so that you can modify and customize it later.
  2. Configure the KEYWORD. Input the area that matters to you, like ChatGPT. Only support one keyword right now. After that, click on Create and Deploy.
  3. Authorize bot access to Slack. The slack_workspace and slack_channel point to the target Slack channel where the bot will send you the ChatGPT-related Hacker News Post. Input your Slack workspace and channel here. Next, click on Connect to give the repo the necessary permissions in Slack.

Click here to see how to create a Hacker News Alert Slack bot in three steps.

That’s it. After that, you will receive a message if the Hacker News Post contains ChatGPT every hour at the 50th minute. Then, you won’t miss any Hacker News Posts related to ChatGPT.

What is the difference between Hacker News RSS and a Slack bot

Compared with Hacker News RSS, one of the advantages of a Hacker News Slack bot is that the bot can be integrated into the SaaS tools you often use. But with Hacker News RSS, you need to install an extra tool to read the RSS feed.

Furthermore, you can also integrate ChatGPT into this Slack bot and ask ChatGPT to summarize all the Hacker News Posts.

If you own a community on Discord, check out the Discord version to monitor Hacker News posts containing the keyword you're interested in and ask ChatGPT to give a summary of each post.

Give it a try now! Join flows.network Discord server to get the latest updates or request some features.

· 7 min read

ChatGPT has taken the world by storm. However, it's desktop web browser UI is cumbersome and delivers a subpar conversation experience for users. Users already have messaging apps they love and use. We should bring ChatGPT to messaging apps and enable users to converse with ChatGPT anytime anywhere.

Telegram is a popular messaging app that allows users to securely send messages, files, and media to individuals or groups. In this article, I will walk through how to build a ChatGPT bot on Telegram. I will further discuss how to customize your bot with your own prompts and how to access external services from the bot (ie similar to ChatGPT plugins in the desktop web UI).

The bot is deployed on flows.network, a serverless platform for automating SaaS workflows with AI workloads.

What is a telegram bot

Before we started, let’s first understand how a telegram bot works. If you are familiar with Telegram bots, you can skip this part and go to the next part to create a ChatGPT telegram bot.

Essentially, a Telegram bot is a software application that runs inside the Telegram app. It allows us to interact with it using text messages or commands. Telegram bots are built using APIs, which enable developers to create custom code to handle different types of messages and perform various actions.

You can use telegram bot to automate repetitive receptive tasks, such as send a welcome message to the new member. You can also integrate telegram with other SaaS. This is what exactly we are doing right now — integrate Telegram with ChatGPT.

Create a general ChatGPT Telegram bot from a flow template in 3 minutes

With ChatGPT's integration on Telegram, you can easily communicate with ChatGPT without the need to open an additional browser. This feature provides a convenient way to seek assistance from ChatGPT using Telegram's interface.

Make sure you have signed up for an account for flows.network.

  1. Load the ChatGPT based Telegram bot template and click on the Create and Build button. The template contains the source code for the bot itself. flows.networl will clone the source code to your own GitHub account so that you can modify and customize it later. We will use the code to combine awesome prompts with this telegram bot.

get the source code for the ChatGPT Telegram bot

  1. Give the bot your OpenAI API key. Click the Connect button to add your OpenAI API key. If you have saved API keys in the past, you can skip this step and reuse these keys.

get the source code for the ChatGPT Telegram bot

  1. Configure the Telegram API token. This is to connect the function with your bot. You can get a telegram API token from @botfather and paste the box here. Once you're done, the grey Deploy button will turn purple.

get the source code for the ChatGPT Telegram bot

That’t it. After the function is ready and the status of flow is running, you can give your own ChatGPT Telegram bot a try. You can ask this ChatGPT Telegram bot to polish your english writing, being a writing tutor, and explain the code with different prompts.

get the source code for the ChatGPT Telegram bot

Advanced: Import awesome ChatGPT prompts to your telegram bot

The ChatGPT prompts marketplace is another hot topic with the fire of ChatGPT. Prompting is critical for getting more accurate and efficient output from the language model. This is particularly important in fields such as question-answering, language translation, and chatbot development, where the output quality is directly related to the accuracy of the prompts used. A well-written prompt is an essential tool for improving the accuracy, efficiency, and usability of artificial intelligence systems in a wide range of applications. We have seen lots of ChatGPT prompts marketplace on the market, like the open-sourced awesome-chatgpt-prompts GitHub repo, AwesomeChatGPT, FlowGPT and so on.

In this section, I will show you how to add your favourite prompts to the ChatGPT Telegram bot you just built. The customized ChatGPT Telegram bot can be fine-tuned for a specific task. Here I use a prompt from AwesomeChatGPT.

I want you to act as an AI writing tutor. I will provide you with a student who needs help improving their writing and your task is to use artificial intelligence tools, such as natural language processing, to give the student feedback on how they can improve their composition. You should also use your rhetorical knowledge and experience about effective writing techniques in order to suggest ways that the student can better express their thoughts and ideas in written form.

To achieve this goal, we need to change the source code of the repo we created for you in the above step. You can find the GitHub repo address from the flow details page.

get the source code for the ChatGPT Telegram bot

Then go to the src file of your source code repo and replace the existing ChatGPT prompt “You are a helpful assistant answering questions on Telegram” with any of the ChatGPT prompt you need in line 22.

Before:

let system = "You are a helpful assistant answering questions on Telegram.\n\nIf someone greets you without asking a question, you can simply respond \"Hello, I am your assistant on Telegram, built by the Second State team. I am ready for your question now!\"";

After:

let system = "I want you to act as an AI writing tutor. I will provide you with non-native english speakers who needs help improving their writing and your task is to use artificial intelligence tools, such as natural language processing, to give the student feedback on how they can improve their composition. You should also use your rhetorical knowledge and experience about effective writing techniques in order to suggest ways that the student can better express their thoughts and ideas in written form. \n\nIf someone greets you without asking a question, you can simply respond \"Hello, I am your assistant on Telegram, built by the Second State team. I am ready for improving your English writing now!\"";

After making the necessary changes, push them to the GitHub repository and flows.network will automatically build your function. Once the build is complete, you will receive a customized ChatGPT Telegram bot for your specific use, eliminating the need to prompt ChatGPT when you strat a new conversation.

Access external web services

The flow function behind the bot has access to the web. That allows the Telegram to use the latest information and web services injunction with ChatGPT. In another word, you can build ChatGPT plugin-like functionalities into your own bot. This example shows how to make HTTPS requests to an external web service to look up the current weather and parse the result from the response JSON data.

fn get_weather(city: &str) -> Result<ApiResult, String> {
let mut writer = Vec::new();
let api_key = std::env::var("API_KEY").unwrap();
let query_str = format!(
"https://api.openweathermap.org/data/2.5/weather?q={city}&units=metric&appid={api_key}"
);

request::get(query_str, &mut writer)
.map_err(|e| e.to_string())
.and_then(|_| {
serde_json::from_slice::<ApiResult>(&writer).map_err(|_| {
"Please check if you've typed the name of your city correctly".to_string()
})
})
}

Combining ChatGPT with the web, your Telegram bot could be the conversational UI for complex applications. You can also call external web services to perform real world actions — for example, you could call the Twilio API to make a phone call based on ChatGPT outputs.

What’s next?

With flows.network, you can create a ChatGPT-powered Telegram bot in just three minutes. You can personalize your bot by making changes directly to the bot’s source code. For example, you can customize it with your favorite prompts or use external web services to provide additional context or to perform real world actions.

What are you waiting for? Give it a try today! Feel free to join our Discord server to stay updated or to provide feedback.