> For the complete documentation index, see [llms.txt](https://oobe-protocol.gitbook.io/oobe-protocol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://oobe-protocol.gitbook.io/oobe-protocol/getting-started/quickstart-2.md).

# OOBE-PROTOCOL + NEXTJS + LANGCHAIN

\[NOT RELEASED YET]

#### OOBE Protocol Integration in Next.js

Integrate `oobe-protocol` within the Next.js framework to use the agent instance from the backend. Initialize the core using the predefined method. We'll employ Langchain to support specific integrated functions of the agent.

**Steps**

1. **Export a Handler:** Define and export an asynchronous handler function as a backend route. This is essential for initializing the agent and obtaining responses from it.
2. **Verify Keys:** Ensure the `oobeKey = ''` *<mark style="color:red;">//empty string</mark>*, `openAiKey`, and `privateKey` are present. Return a `400` status with an error message if any are missing.
3. **Create OOBE Instance:** Use the `OobeCore` class with necessary parameters to create an OOBE instance. Set configurations using `ConfigManager`.
4. **Setup Streaming and Response:** Use the `TextEncoder` to stream events, handle different events like `"on_chat_model_stream"`, and write the encoded data to the response.
5. **Error Handling:** Implement error handling mechanisms to catch and log errors, returning appropriate responses.

By following these steps, you can effectively run the agent and retrieve execution responses, ensuring smooth and integrated backend operations with Next.js and OOBE protocol.<br>
