This application is your bridge between popular chat platforms like Discord and Slack and the powerful minds of LLMs like OpenAI and Google Gemini. It empowers you to build AI bots with unique personalities that can seamlessly engage in conversations with users.
encore app create my-ai-chat --example=ai-chat
(Feel free to replace my-ai-chat with a name that tickles your fancy)
cd my-ai-chat
encore secret set OpenAIKey --type dev,local,pr,prod
Paste your OpenAI API key when prompted.
encore run
Encore will build and start your application, providing you with a local URL (e.g., http://127.0.0.1:4000). Open this URL in your browser to see your creation - the local chat interface!
Ready to share your bots with the world? Encore makes deploying to a free testing environment a breeze:
git push
Encore will guide you through the deployment process and provide a link to your live application.
Once the deployment is complete, click Overview and copy the URL to see your bots in action on the web!
AI Chat is a microservices-based application, with each service handling a specific aspect of the chatbot ecosystem. The services uses a combination of Encore APIs, pub/sub messaging, and WebSocket communication to orchestrate the flow of messages between chat platforms and LLM providers. You can explore the services and their interactions in the Local Dashboard.
LLMs are the heart and soul of your bots, providing the intelligence and personality that make them shine. This application is built to make it easy to integrate with popular LLM providers, and it comes pre-configured to work with OpenAI and Google Gemini. The only thing you need to do is set your credentials as Encore secrets, and you're ready to start generating bots with your chosen LLM provider.
To enable OpenAI as an LLM provider, you'll need to set your OpenAI API key as an Encore secret. Here's how you can do it:
encore secret set OpenAIKey --type dev,local,pr,prod
bot.Create endpoint with openai as the provider.To enable Gemini as an LLM provider, you'll need to set your Google Cloud credentials as an Encore secret. Here's how you can do it: To enable Gemini as an LLM provider, you'll need to set your Google Cloud credentials as an Encore secret. Here's how you can do it:
Create Service Account and give your new account a name and description.Vertex AI User role.Done.Keys -> Add Key -> Create New.JSON format and click Create.encore secret set --type dev,local,pr,prod GeminiJSONCredentials < <downloaded json>.json
bot.Create endpoint with gemini as the provider.The application is designed to make it easy to integrate with any chat platform, but it comes pre-configured to work with Discord and Slack. It also includes a local chat service with an easy-to-use web interface which is hosted on the API server. The local chat service is enabled by default, but Slack and Discord require additional setup to connect your bots to these platforms.
http://localhost:4000/).Enabled property to false in the chat/provider/local/config.cue file.To be able to use Slack as a chat platform, you'll need to create a Slack app and add it to your workspace. Here's how you can do it:
Create New App.From an app manifest and click Next.Next.<bot-domain> placeholder with either <env-name>-<app-name>-<slug>.encr.app (e.g. staging-my-chatbot-tur3.encr.app) or the ngrok domain you configured for local developmentNext and then Create.Event Subscriptions.Request URL is yellow, click on Retry.OAuth & Permissions and then Install to Workspace.Allow.Bot User OAuth Token from the OAuth & Permissions page.encore secret set SlackToken --type dev,local,pr,prod
To be able to use Discord as a chat platform, you'll need to create a Discord bot and add it to your server. Here's how you can do it:
New Application.Create.Installation.Discord Provided Link in Install Link.Default Install Settings, add the bot scope and these permissions:Bot and then Privileged Gateway Intents.Bot page, click Reset Token.encore secret set DiscordToken --type dev,local,pr,prod
The Slack and Discord integrations does not come with a custom-made UI for adding bots to channels. Until you've built your own UI (or maybe addded support for slash commands?), you can use the Encore Dashboards to add bots to channels:
Service Catalogbot.Create endpoint.openai as the LLM.Call API.chat.ListChannels.Call API.id of the channel you want your bot to join.chat.AddBotToChannel endpoint.Call API.You've successfully integrated your chat platforms and LLMs, ready to unleash your AI-powered conversationalists! Now go forth and create bots that will make people laugh, think, or maybe even question the nature of reality (but no pressure!).
If you're developing locally and want to connect to external services like Slack, you'll need to use a service like ngrok to create a secure tunnel to your local development server. This app is pre-configured to work with ngrok, so you can easily test your bots on Slack and Discord without deploying them to the cloud.
Authtokens.Add Tunnel Authtoken.encore secret set NGrokToken --type dev,local,pr,prod
Domains -> New Domain in your ngrok dashboard.encore secret set NGrokDomain --type dev,local,pr,prod
The local chat service uses a web interface to interact with the chat service. If you want to make changes to the interface, you'll need to rebuild it before you deploy your changes.
brew install npm
chat/provider/local/static directory and run:npm install
npm run build
encore run
npm run dev
encore run.This application is your bridge between popular chat platforms like Slack and the powerful minds of LLMs like OpenAI and Anthropic's Claude. It empowers you to build AI bots with unique personalities that can seamlessly engage in conversations with users.
AI Chat is a microservices-based application, with each service handling a specific aspect of the chatbot ecosystem. The services uses a combination of Encore APIs, pub/sub messaging, and WebSocket communication to orchestrate the flow of messages between chat platforms and LLM providers. You can explore the services and their interactions in the Local Dashboard.
LLMs are the heart and soul of your bots, providing the intelligence and personality that make them shine. This application is built to make it easy to integrate with popular LLM providers, and it comes pre-configured to work with OpenAI and Anthropic. The only thing you need to do is set your credentials as Encore secrets, and you're ready to start generating bots with your chosen LLM provider.
To enable OpenAI as an LLM provider, you'll need to set your OpenAI API key as an Encore secret. Here's how you can do it:
encore secret set OpenAIKey --type dev,local,pr,prod
bot.Create endpoint with openai as the provider.To enable Claude as an LLM provider, you'll need to set your Anthropic key as an Encore secret. Here's how you can do it:
Create Key and give your key a fancy name2Add Key as an Encore Secret:
encore secret set --type dev,local,pr,prod ClaudeKey
3Generate Bots:
All done! You can now generate bots with Claude as the LLM, just call the bot.Create endpoint with claude as the provider.
The application is designed to make it easy to integrate with any chat platform, but it comes pre-configured to work with Slack.
To be able to use Slack as a chat platform, you'll need to create a Slack app and add it to your workspace. Here's how you can do it:
Create New App.From an app manifest and click Next.Next.<bot-domain> placeholder with either <env-name>-<app-name>-<slug>.encr.app (e.g. staging-my-chatbot-tur3.encr.app) or the ngrok domain you configured for local developmentNext and then Create.Event Subscriptions.Request URL is yellow, click on Retry.OAuth & Permissions and then Install to Workspace.Allow.Bot User OAuth Token from the OAuth & Permissions page.encore secret set SlackToken --type dev,local,pr,prod
The Slack integration does not come with a custom-made UI for adding bots to channels. Until you've built your own UI (or maybe addded support for slash commands?), you can use the Encore Dashboards to add bots to channels:
Service Catalogbot.Create endpoint.openai as the LLM.Call API.chat.ListChannels.Call API.id of the channel you want your bot to join.chat.AddBotToChannel endpoint.Call API.You've successfully integrated your chat platforms and LLMs, ready to unleash your AI-powered conversationalists! Now go forth and create bots that will make people laugh, think, or maybe even question the nature of reality (but no pressure!).
Ready to share your bots with the world? Encore makes deploying to a free testing environment a breeze:
git add .
git commit -m "Deploying my awesome bots!"
git push
The push command will trigger a deployment to the Encore cloud and share a link to the deployment job.
Once the deployment is complete, click Overview and copy the URL to see your bots in action on the web!
If you're developing locally and want to connect to external services like Slack, you'll need to use a service like ngrok to create a secure tunnel to your local development server. This app is pre-configured to work with ngrok, so you can easily test your bots on Slack without deploying them to the cloud.
Authtokens.Add Tunnel Authtoken.encore secret set NGrokToken --type dev,local,pr,prod
Domains -> New Domain in your ngrok dashboard.encore secret set NGrokDomain --type dev,local,pr,prod
The local chat service uses a web interface to interact with the chat service. If you want to make changes to the interface, you'll need to rebuild it before you deploy your changes.
brew install npm
chat/provider/local/static directory and run:npm install
npm run build
encore run
npm run dev
encore run.