Share product ideas and upvotes with our product team
Integrating artificial intelligence into web apps can help build dynamic and engaging user experiences. When we take full advantage of large language models from platforms such as OpenAI, developers can build smart AI apps that generate text, auto-summarize content, and even answer questions. The AI software market will reach a valuation of USD 12.6 billion by the year 2028. We have formed a detailed walkthrough with a step-by-step Next.js OpenAI API tutorial integration.Why Next.js and OpenAI Are a Perfect MatchNext.js is a powerful React framework that excels at building production-ready applications. It comes with several promising features, including server-side rendering (SSR) and API routes. This makes it an ideal environment for interacting with external APIs, such as OpenAI. We utilize Next.js API routes to store sensitive API keys on the server. Hire Next.js developers who take this server-side approach to build complex, data-driven, smart applications.OpenAI’s API provides programmatic access to its ecosystem of powerful models. Combining the secure architecture provided by Next.js with the advanced AI capabilities of the OpenAI API enables people to build intelligent, AI-based applications. If your project requires this level of expertise and you need a dedicated team to help, you may want to consider professional frontend development services or hire Next js developer to bring your vision to life.Step-by-Step Guide to Setting Up Next.js Open AI IntegrationStep 1: Project Setup and DependenciesStart by setting up a new Next.js project. Install all the needed libraries, and use the official OpenAI Node.js package for making API calls. For an advanced app experience, especially for chat applications, you can also integrate Intercom with ChatGPT to enhance user support and engagement. Additionally, consider using the Vercel AI SDK to streamline the interface for various AI services.In your terminal, navigate to your project directory and run the following command:npm install openai ai @ai-sdk/react @ai-sdk/openaiopenai: The official SDK for interacting with the OpenAI API. ai: The core AI SDK from Vercel. @ai-sdk/react: React-specific hooks for the AI SDK, like useChat, which simplifies building chat UIs with streaming responses. @ai-sdk/openai: An adapter that makes the OpenAI API compatible with the AI SDK.Step 2: Securing Your OpenAI API KeySecurity is paramount. You must never expose your OpenAI API key on the client side. The best practice is to store it as an environment variable on your server.In the root of your project, create a file named .env.local and add your API key:OPENAI_API_KEY=your_openai_api_key_hereReplace your_openai_api_key_here with your actual key. Next.js automatically loads these variables at runtime. Remember to restart your development server (npm run dev) if you add or change this file.Step 3: Setting Up Next.js API RoutesAPI routes are the secure backbone of our application. They act as a serverless function that handles requests from the frontend, communicates with the OpenAI API, and sends back the response. This prevents your API key from ever reaching the user's browser.If you're using the App Router, which is the modern standard for Next.js, create a file at app/api/chat/route.ts. This file will handle POST requests from the frontend.app/api/chat/route.tsTypeScriptimport OpenAI from 'openai';import { OpenAIStream, StreamingTextResponse } from 'ai';const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY,});export async function POST(req: Request) { const { messages } = await req.json(); const response = await openai.chat.completions.create({ model: 'gpt-4o', // Or a different model like 'gpt-3.5-turbo' stream: true, messages: messages, }); const stream = OpenAIStream(response); return new StreamingTextResponse(stream);}This code snippet highlights a few key points:Security: It uses process.env.OPENAI_API_KEY, which is only available on the server. Streaming: The stream: true option tells OpenAI to send the response in chunks as it's being generated. The Vercel AI SDK's OpenAIStream then formats this into a stream the frontend can easily consume. This is a game-changer for perceived performance.Step 4: Building the FrontendNow for the client-side you should opt for reliable frontend development services. We will make a simple user interface that sends user input to our API route and displays the AI's response. The Vercel AI SDK's useChat hook makes this remarkably easy, handling all the state management and streamlining the logic for us.In your app directory, let's create a component.app/page.tsxTypeScript'use client';import { useChat } from 'ai/react';import { FormEvent } from 'react';export default function ChatComponent() { const { messages, input, handleInputChange, handleSubmit } = useChat(); return ( <div className="flex flex-col h-screen p-8 bg-gray-100 text-gray-800"> <h1 className="text-3xl font-bold mb-4 text-center text-blue-600">AI Chatbot</h1> <div className="flex-1 overflow-y-auto mb-4 p-4 border border-gray-300 rounded-lg bg-white shadow-inner"> {messages.map((m) => ( <div key={m.id} className={`mb-2 p-2 rounded-lg max-w-lg ${m.role === 'user' ? 'bg-blue-200 self-end text-right' : 'bg-gray-200'}`}> <p className="font-semibold">{m.role === 'user' ? 'You:' : 'AI:'}</p> <p className="whitespace-pre-wrap">{m.content}</p> </div> ))} </div> <form onSubmit={handleSubmit as (e: FormEvent<HTMLFormElement>) => void} className="flex space-x-2"> <input className="flex-1 p-3 border border-gray-400 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" value={input} onChange={handleInputChange} placeholder="Say something to the AI..." /> <button type="submit" className="p-3 bg-blue-600 text-white rounded-lg font-bold hover:bg-blue-700 transition duration-300" > Send </button> </form> </div> );}The frontend is simple. Thanks to the useChat hook. You don’t have to manage all the background tasks. It provides ease of managing access, history, user input, and streams responses from the AI as they arrive. The UI updates in real time, so everything feels smooth and responsive as you chat.Best Practices and Further ConsiderationsError HandlingThings won’t always go smoothly, so it's important to plan for errors. Ensure your app can identify and respond to issues such as failed API requests or invalid inputs with helpful, easy-to-understand messages, rather than displaying technical errors or blank screens.Rate LimitingIf your app is live and being used regularly, you’ll want to put some limits in place to prevent users from making multiple requests too quickly. This helps protect your system and limits you from exceeding your API quota too quickly.Choosing the Right ModelNot all tasks require you to use the most powerful model. GPT-4o has high potential, but it is more expensive. If you are performing a basic task, such as text summarization or Q&A, gpt-3.5-turbo may be all you need.Final WordsBy following this Next.js OpenAI integration tutorial, you can easily add the OpenAI API to a Next.js application. Using API routes and the Vercel AI SDK, you can mention a secure, efficient, and user-friendly way to integrate the power of AI into your projects. This foundation offers a range of applications, including a Next.js AI app and content generation tools. The OpenAI API is a powerful tool, and combined with Next.js, it allows you to build intelligent web applications that truly stand out.
We have multiple stores and will need multiple guidances set for each store. Currently, I’m differentiating them by their name. For example: [FL] Cancelation policy and [CA] Cancelation policy. While this categorization works for me, I would really like having an option to drag and move guidances so I could have them organized by store. Currently, it’s a bit of a mess since they are listed from oldest to newest.
Hi, I have some tickets in my inbox that sits there because I need to do a review on how Fin handled them, hoever they a bloating my inbox while they are in this state. Would be awesome to “Save for AI review” or something, to remove them from my table and have them saved for later.
I’ve noticed that the suggestions provided by the Fin for snippets or articles can be extremely repetitive. While doing an analysis today—although I don’t have the exact number—I can say with confidence that at least 10 suggestions covered the same topic.This particular topic has indeed been very common in our support over the past few months, but I believe it would be valuable for the Fin to apply some kind of filter to avoid suggesting redudant things. This would prevent the suggestion box from becoming cluttered with duplicates and help us focus on new, unique ideas.
We need to make Fin do something after customer confirms resolution.Right now, if Fin resolves a conversation, he just say Bye and that’s it. We need to be able to either: Add action on Confirmed Resolution in Workflows (just like when we can add paths on escalation) Or, have a trigger for When fin resolves a caseOur goal is to ask the customer for CSAT and then take action depending on the user input. You can easily achieve this in a normal Workflow, but we cannot do nothing for the cases where Fin resolves the case
FIN usually stops responding as soon as I respond to a conversation, whether the customer asks to talk to a person or not. I would like the ability to turn FIN back on for any new questions the customer asks
One of the great advantages of language models such as GPT, is that it can easily cover a huge variety of different tones in the language and by that - be more human. In my feeling, this is also one of the main benefits comparing Fin to a classic Chat Bot Model.However, I feel in the current implementation Intercom lacks way behind, of what could actually be achievable here. Many other GPT based custom bots allow a setting called “Custom base prompt”, which adds a custom user input to the base prompt of the conversation, before the bot answers. This would allow users, to actually custom brand the tone of their Chatbot and match to their brand.Intercom customers cover a huge range of different industries, corporate scales and end-customer groups, which currently all get addressed the same way, although GPT would actually be able to to this way more personal. I want to give you an example:Our customers are graduation students, so Gen-Z individuals. Fin answers very professionally atm, as it would talk with a 60 years old corporate purchaser. By adding an input field to the Fin Profile like “Set a custom tone of voice for Fin” we as a company could write there: “You are talking with Gen-Z individuals and should use a very relaxed and young communication style. Feel free to build in jokes to your answers, but to not exaggerate. Keep your answers as short as possible.” … we could adapt the voice tone of Fin to actually work seamlessly with our customers and add a huge benefit, compared to a classic chat bot.From product perspective there may be a concern of manipulating the Fin answer style too hard via the free text input, so as a variant to the implementation idea on top, I could also imagine selection dropdowns instead of free text input. Something like:Communication tone: Professional (Default) | Funny | Rough | Flirty | Poem …Main Target Audience: 16-24 | 24-38 | 39-50 ...( or millieus, industries, free input, tbd)etc. TLDR: Setting to set custom voice tone of Fine to align with brand communication style
Hi Intercom Team,Our company is heavily investing into automation and AI tooling and we would love to retrieve Intercom data via our tooling. I see a huge progress on hosting Intercom instances in Europe.Could you please enable Intercom MCP for accounts hosted in Europe?Wishes,Jakub
Most of our users are looking for a simple quick answer to simple questions. A picture tells a thousand words so we would really want the ability to PASTE AN IMAGE into the suggested answer
Hello,Hoping to have the ability to ask a follow up question when testing questions in the Fin AI section.Sometimes the first answer is correct but I want to see if a customer were to ask a logical follow up question, what would be said from there. Also, now that the testing continues to be amazing, sometimes in the FinAI response it leaves off with a question. I’d like to be able to answer that question in testing and see what it says.Thank you for your consideration.
When a customer has a conversation with Fin only (no human interaction) and responds negatively to that conversation, it’d be so handy for there to be an option or workflow that automatically re-opens the conversation and escalates to human support. Currently, if a customer gives Fin a bad CSAT it’s logged on a report that a human must review to re-open if needed. This relies on the person reviewing to get back to the customer in a timely manner which won’t always be possible and takes resource. If a workflow automatically re-opens the conversation and assigns it to a human for further assistance as soon as it happens it’s a better experience for the customer and streamlines the process.
We like the FIN first experience where the launcher opens directly to a FIN conversation, however, we would much prefer if when the back arrow is clicked that it took the user to the HOME tab instead of the MESSAGES tab. We have a lot of good stuff on the home tab, and some of our users don’t understand that they need to click the back arrow and then click again to get to the HOME tab. another idea would be that in the FIN conversation window, below where you enter your question, you could still see the launcher tabs for home and messages, etc.
While you can use the Topic filter in reports, it’s not available in views in real time, which makes tracking issues in real-time more limited. Especially with the upcoming AI topic improvement, I think that would be super helpful to have available.
Hi everyone! We were recently reviewing our Intercom workflows with Fin and noticed a couple of things that could improve the overall experience, both for our users and our support team. So here I am with some feature requests :) Make the 4-minute inactivity timer adjustable – In many cases, 4 minutes isn’t enough for users to check proposed solutions. It can make them feel rushed or like we’re trying to close the conversation too quickly. Having control over this timer would help us better match the user’s workflow. Customize the “Was that helpful?” message (timing + copy) – Sometimes this question appears after every reply, which feels robotic and breaks the flow (and doesn’t help the conversation with the bot feel “more human”). We’d love to control how often it shows up and adjust the message to better fit our tone and conversation style.
Currently when testing new guidance with Fin we can only test how it will react in web chat. In the Preview/Test environment we’re unable to select which incoming channel the communication would be coming through. More specifically we would like to test SMS interactions to tailor the guidance for how customers will engage with Fin over SMS while keeping in mind things like character limits, linking references, surveying, and timing delays for large messages. Currently the only settings are for changing the user type, brands, and language.
Already have an account? Login
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.