Skip to main content

How to Integrate AI Chatbot with LikeMinds Android Chat SDK

· 8 min read

In this guide, we will cover the steps to integrate an AI chatbot with LikeMinds Android Chat SDK, including chatbot setup, managing conversations, and handling AI responses, to create a dynamic, intelligent chat experience in your Android application.

Step 1: Create an Open AI Assistant on the OpenAI Platform

To begin, you'll need to create an AI Assistant on the OpenAI platform. This assistant will help developers with their queries regarding API and SDK integration for feed and chat products. The assistant will leverage a vector store containing documentation files to provide accurate and contextually relevant responses. Follow these steps to set up the assistant:

  1. Sign Up/Login to OpenAI: Visit OpenAI and sign up for an account or log in if you already have one.

  2. Access API Settings: Navigate to the API section from the dashboard.

  3. Create a New API Key: Generate a new API key for your AI Assistant, which will be used for authentication and interaction with your chatbot. Save this API key for sharing it to LikeMinds via REST-API.

  4. Define Your Model: Select a suitable language model (e.g., GPT-4) for your assistant, based on your use case.

  5. Create Vector Store:

    • Go to Vector Stores and create a new vector store.
    • Attach Files: Upload all the relevant documentation files (e.g., "Android Chat Integration" files) to the vector store. This allows the assistant to reference these documents when responding to queries.
  6. Create Assistant:

    • Navigate to OpenAI Assistants and create a new assistant.
    • Copy the assistant ID for future use
    • Add Instructions: In the assistant's configuration, provide the guidelines as per your requirements to ensure it delivers accurate, clear, and concise responses

    Here's a sample Assistant Instructions for SDK integration assistant:

     You are an intelligent assistant designed to help developers with their queries around API and SDK integration for feed and chat products. You have access to a comprehensive vector store containing documentation files related to these integrations. Your role is to provide clear, accurate, and concise answers to help developers resolve their issues effectively.

    When responding to queries, consider the following guidelines and constraints:

    - **Understand the Query**: Ensure you fully understand the developer's question before providing an answer.
    - **Leverage Documentation**: Use the vector store documentation to support your responses. Refer directly to specific sections or examples when possible.
    - **Clarity and Precision**: Provide clear and precise instructions or explanations. Avoid ambiguity.
    - **Examples and Code Snippets**: Include relevant examples or code snippets from the documentation to illustrate your points.
    - **Additional Resources**: If applicable, guide the developer to additional resources or sections in the documentation that might be helpful.
    - **Follow-up**: Encourage the developer to ask follow-up questions if they need further clarification.

    ### Constraints:

    - **Accuracy**: Ensure all provided information is accurate and up-to-date with the latest version of the documentation.
    - **Relevance**: Only provide information relevant to the query. Avoid unnecessary details that may confuse the developer.
    - **Security**: Do not share sensitive information such as API keys, passwords, or any proprietary data that is not meant for public consumption.
    - **Privacy**: Do not log or store any personal data of the users asking queries.
    - **Performance**: Respond to queries promptly, ensuring minimal latency between the question and your response.
    - **Format Consistency**: Maintain a consistent format in your responses for readability and ease of understanding. Use proper indentation and syntax highlighting for code snippets.
  7. Connect Vector Store to the Assistant : In the assistant setup, link the vector store you created. This will enable the assistant to access and search through the documentation to provide accurate, context-driven responses.

  8. Test Your Assistant: Use the playground option on the OpenAI platform to test your assistant’s responses, ensuring it correctly uses the uploaded documentation and follows the specified instructions.

Step 2: Create an API Key for LikeMinds SDK

To integrate the LikeMinds Android Chat SDK with your AI chatbot, you will need to create an API key from the LikeMinds dashboard. This API key will authenticate your application and allow it to access LikeMinds services, including Direct Messaging (DM) features. Follow the steps below to generate your API key and enable DM settings:

  1. Login to LikeMinds Dashboard: Visit the LikeMinds Dashboard, log in with your credentials and create a Project to get the API Key. Save the API Key for all the futures usage in Android SDK and calling any API.

  2. Get the Owner Bot ID: Navigate to Members section and Get the Unique Id of the Owner Bot for further use. Save the the Unique ID for futures usages for calling APIs.

With this API key, you can now move forward with connecting the LikeMinds SDK to your AI chatbot, allowing your application to manage user interactions and conversations effectively.

Step 3: Add the AI Assistant to LikeMinds Chat

Now that you have set up the AI assistant and generated the API key, it's time to integrate the AI assistant with LikeMinds Chat. This step involves obtaining the accessToken, enabling the AI chatbot settings, and creating a chatbot user in your project.

  1. Get Access Token Using LikeMinds SDK Initiate API: Before enabling the chatbot, you need to obtain the accessToken for Owner Bot. This token is necessary for authenticating API calls. Call the POST sdk/initiate API to login with Owner Bot ID credentials. You can fetch the user unique id and API key from the dashboard and add in the respective placeholder below.
curl --location 'https://auth.likeminds.community/sdk/initiate' \
--header 'x-api-key: {LIKEMINDS_API_KEY}' \
--header 'x-sdk-source: chat' \
--header 'x-api-version: 1' \
--header 'Content-Type: application/json' \
--data '{
"uuid": "{UUID_OF_OWNER_BOT_FROM_DASHBOARD}",
}'

When you receive a 200 response in the response body data.access_token will be used as Authorization token in the following APIs.

  1. Enable AI Chatbot Settings: Once you have the accessToken, make an API call to enable the AI chatbot settings for your project.
curl --location --request PATCH 'https://auth.likeminds.community/community/configurations' \
--header 'Authorization: Bearer {ACCESS_TOKEN}' \
--header 'x-platform-type: dashboard' \
--header 'Content-Type: application/json' \
--data '{
"description": "Chatbot configurations for the community",
"type": "chatbot",
"value": {
"api_key": "{API_KEY_FROM_OPEN_AI}",
"enabled": true,
"error_message": "", //Custom Error Message you want your bot to respond in case of failure
"provider": "open_ai_assistant"
}
}'
  1. Create a Chatbot User: After enabling the chatbot settings, create a new user to represent the AI chatbot within your chat application.
curl --location 'https://auth.likeminds.community/community/chatbot' \
--header 'Authorization: Bearer {ACCESS_TOKEN}' \
--header 'x-platform-type: dashboard' \
--header 'Content-Type: application/json' \
--data '{
"name": "{NAME_OF_CHATBOT}",
"chatbot_meta": {
"provider": "open_ai_assistant",
"provider_meta": {
"default_text": "{DESCRIPTION_FOR_CHATBOT}",
"assistant_id": "{ASSISTANT_ID_FROM_OPEN_AI}"
}
}
}'

Once these steps are completed, your AI chatbot will be successfully added into LikeMinds Chat and can interact with users by providing automated responses in chatrooms.

Step 4: Integrate Android Chat SDK

To enable real-time chat functionality in your application, you will now integrate the LikeMinds Android Chat SDK. This SDK will allow the AI chatbot to interact with users within the chat interface, handling conversations seamlessly.

For detailed instructions on setting up the Android Chat SDK, please follow this Getting Started with LikeMinds Android Chat SDK

Once the SDK is integrated, your app will be ready to handle user interactions and AI-driven responses in the chat interface.

Step 5: Start Using AI Chatbot

With the AI assistant successfully integrated and the Android Chat SDK configured, your chatbot is now ready to come to life within your application. You can now easily interact with the AI-powered chatbot in real-time. Follow these simple steps to start your conversation and experience the chatbot in action:

  1. Run the Android Application: Launch your Android app with the integrated LikeMinds Chat SDK.

  2. Open the DM Tab: Navigate to the Direct Messaging (DM) section of your app.

  3. Tap on the New DM (Floating Action Button): This will allow you to start a new conversation.

  4. Find the Chatbot: Search for chatbot user that was created in Step 3 and Tap on the user to start the conversation.

  5. Start the Conversation: Tap on the chatbot to begin a conversation. The AI assistant will now respond to your queries and interact with you based on the configurations set up in the previous steps.

Your AI chatbot is now fully functional and ready to assist users in real-time within your chat application.

Conclusion

With the AI chatbot now fully integrated into the LikeMinds Android Chat SDK, your chat application is equipped to handle real-time, automated responses. The chatbot can assist users by answering queries, providing support, and improving engagement through seamless interactions.

By using OpenAI's assistant with the connected vector store, your chatbot can access relevant documentation to provide accurate and helpful responses. This setup reduces manual effort and creates a smoother, more dynamic user experience.

You can continue to expand the chatbot's capabilities by adding more documentation, adjusting its behavior, or tailoring it to meet specific user needs. This integration offers a powerful solution for improving your chat application's overall functionality and user satisfaction.