π Get the code here:
https://github.com/XamHans/botpress-nextjs
β Make sure that your bot is deployed!
πΉ Video Tutorial:
https://www.youtube.com/watch?v=zUTFqEeA0NI&ab_channel=HayerHans
π Key Steps Covered:
π Clone the repo with:
git clone https://github.com/XamHans/botpress-nextjs.git
π cd into the folder and install the dependencies with yarn install
π» start the application with yarn dev
π get the Botpress Webchat Snippet from botpress website
- 𧩠Navigate to the layout.tsx file. In the head section use the Script Component to init botpress
<Script
src="https://cdn.botpress.cloud/webchat/v0/inject.js"
onLoad={() => {
initBotpress();
}}
/>
const initBotpress = () => {
window.botpressWebChat.init({
composerPlaceholder: "Chat with bot",
botConversationDescription:
"This chatbot was built surprisingly fast with Botpress",
botId: "<YOUR_BOT_ID>",
hostUrl: "<YOUR_BOT_HOST_URL>",
messagingUrl: "https://messaging.botpress.cloud",
clientId: "<YOUR_CLIENT_ID>",
});
};
- π οΈ make sure that you type on top of the layout.tsx "use client" to make it a client component.
You have successfully integrated your bot into your next.js 13 app! π
Top comments (1)
Dude, this is a custom integration that needs to be done: botpress.com/docs/building-a-custo...