/lovable-integrations

Lovable and IBM Watson integration: Step-by-Step Guide 2025

Follow our step-by-step guide to integrate Lovable with IBM Watson and boost your AI capabilities for seamless, efficient communications.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to integrate Lovable with IBM Watson?

 

Setting Up Dependencies

 

Since Lovable doesn't have a terminal, you'll add dependency information directly into your project’s code. Create or update your package.json file (typically located at the root of your project) with the IBM Watson dependency. Add the following code snippet to your package.json:


{
  "name": "lovable-project",
  "version": "1.0.0",
  "dependencies": {
    "ibm-watson": "^6.0.0"
  }
}

 

Creating the IBM Watson Service File

 

In your Lovable project, add a new TypeScript file to handle IBM Watson integration. Name this file ibmWatsonService.ts and place it in your source folder (for example, inside a folder named src). Insert the following code into ibmWatsonService.ts. This code imports the IBM Watson Assistant SDK, initializes the service using your credentials, and exports functions to create a session and send a message:


import AssistantV2 from 'ibm-watson/assistant/v2';
import { IamAuthenticator } from 'ibm-watson/auth';

// Replace the placeholders with your actual IBM Watson credentials.
const assistant = new AssistantV2({
  version: '2021-06-14',
  authenticator: new IamAuthenticator({
    apikey: 'your-ibm-api-key-here'
  }),
  serviceUrl: 'your-service-url-here'
});

export async function createSession() {
  try {
    const session = await assistant.createSession({
      assistantId: 'your-assistant-id'
    });
    return session.result.session_id;
  } catch (error) {
    console.error('Error creating session:', error);
    throw error;
  }
}

export async function sendMessage(sessionId: string, message: string) {
  try {
    const response = await assistant.message({
      assistantId: 'your-assistant-id',
      sessionId: sessionId,
      input: {
        'message_type': 'text',
        'text': message
      }
    });
    return response.result;
  } catch (error) {
    console.error('Error sending message:', error);
    throw error;
  }
}

 

Integrating the IBM Watson Service Into Your Application

 

Locate the part of your Lovable project's code that handles user interactions or messaging. Create or update a file (for example, chatController.ts) in your source directory with the following code to integrate the IBM Watson service. This file imports the functions from ibmWatsonService.ts and shows how to create a session and send a message:


import { createSession, sendMessage } from './ibmWatsonService';

async function handleUserMessage(userMessage: string) {
  try {
    const sessionId = await createSession();
    const watsonResponse = await sendMessage(sessionId, userMessage);
    console.log('IBM Watson response:', watsonResponse);
    // Here you can update your UI or further process the response
  } catch (error) {
    console.error('Error handling user message:', error);
  }
}

// This is an example trigger; integrate it with your actual message handler.
handleUserMessage('Hello, Watson!');

 

Configuring Your IBM Watson Credentials

 

Update the placeholders in ibmWatsonService.ts with your actual IBM Watson service credentials:

  • Replace your-ibm-api-key-here with your IBM Watson API key.
  • Replace your-service-url-here with your IBM Watson service URL.
  • Replace your-assistant-id with your IBM Watson Assistant ID.

 

Connecting the Integration in Your Lovable Project

 

Ensure that your main application file is importing and invoking the integration from chatController.ts. Depending on your project structure, you could add an import in your main file (for example, index.ts or app.ts):


import './chatController';
// Other initialization code for your Lovable project...

This inclusion ensures that when your project starts, it loads the IBM Watson integration and is ready to handle messages accordingly.

 

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022