Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linkedin for OMI Web Personas #1752 #1780

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

harshithsunku
Copy link

@harshithsunku harshithsunku commented Feb 9, 2025

Fixes #1752

Added LinkedIn Integration to OMI Personas

Overview

Added LinkedIn profile integration alongside existing Twitter support, enabling users to create AI personas from either platform.

Key Changes

  •  Added LinkedIn API integration
  • ️ Created new components for better code organization:
    • ChatbotList
    • Header
    • Footer
    • InputArea
    • `Profiles '
  •  Updated UI to support both Twitter and LinkedIn profiles
  •  Added LinkedIn-specific data handling:
    • Profile information
    • Connection & follower counts
    • Professional history
    • Skills and posts

Technical Implementation

// New LinkedIn profile fetching
const fetchLinkedinProfile = async (handle: string) => {
  const profileResponse = await fetch(`https://${process.env.NEXT_PUBLIC_LINKEDIN_API_HOST}/profile-data-connection-count-posts?username=${encodedHandle}`, {
  // Process LinkedIn profile data
}

Testing Coverage ✅

  • Twitter-only profiles
  • LinkedIn-only profiles
  • Dual-platform profiles

Environment Variables Added

NEXT_PUBLIC_LINKEDIN_API_HOST=
NEXT_PUBLIC_LINKEDIN_API_KEY=

image

image

Snip from firebase:
image

Pop Up if profile exists in both platforms

image

Flow Diagram for Profile selection and creation

graph TD
    A[User Enters Handle] --> B{Is Profile exist?}
    B -->|Not Found| C{Check Platform Availability?}
    B -->|Found| D{Where Does it Exist?}
    C -->|Twitter Only| E[Create Twitter Profile]
    C -->|LinkedIn Only| F[Create LinkedIn Profile]
    C -->|Both Available| G[fetch and create both]
    C -->|Not Available| H[Show Error: Profile Not Found]
    D -->|Twitter Only| I{Is Linkedin Available?}
    I -->|No, Route to twitter chat|R
    I -->|Yes|S
    D -->|Both| K{Select platform twitter/linkedin?}
    D -->|LinkedIn Only| J{Is Twitter Available?}
    S -->K
    J -->|Yes|T
    J -->|No, Route to Linkedin Chat|R
    T -->K
    K -->|Based on user selection linnked or twitter| R
    E --> L[Route to New Chat]
    F --> L
    G --> M{Selected Platform twitter/linkedin?}
    M -->|LinkedIn/Twitter based on selection| L
    R[Route to chat]
    S[Fetch and create Linkedin]
    T[Fetch and create Twitter]
Loading

Flow Diagram of Code for Profile selection

graph TD
    A[User enters Handle] -->B[Scrape handle ONLY if Not exists in DB,For both twitter and linkedin scrape and save in DB]
    B --> C{Check Platform Avalibality?}
    C -->|if hanle not found| E[toast error profile not exists]
    C -->|Only Twitter| D[Route to Chat]
    C -->|Only Linkedin| D
    C -->|Both platform for same handle| F{Popup to select twitter or linkedin}
    F -->|twitter or linkedin based on selection| D
Loading

Test Case: Twitter URL Only
Input Example: https://x.com/harshithsunku
Expected Outcome: Extracts clean handle as harshithsunku. Only fetchTwitterProfile is called. Retrieves the Twitter docId and redirects to chat without displaying a platform modal.
Status: PASS
Comment: Verified that when a Twitter URL is provided, only the Twitter profile is fetched, even if the same handle exists for LinkedIn.

Test Case: LinkedIn URL Only
Input Example: https://linkedin.com/in/harshithsunku
Expected Outcome: Extracts clean handle as harshithsunku. Only fetchLinkedinProfile is called. Retrieves the LinkedIn docId and redirects to chat without displaying a platform modal.
Status: PASS
Comment: Verified that when a LinkedIn URL is provided, only the LinkedIn profile is fetched, ignoring the Twitter branch even if it exists.

Test Case: Plain Handle (Ambiguous, Multi-platform)
Input Example: harshithsunku or @harshithsunku
Expected Outcome: Extracts the clean handle as harshithsunku. Both fetchTwitterProfile and fetchLinkedinProfile are triggered. If both API calls succeed, a modal is shown for platform selection.
Status: PASS
Comment: Verified that plain handle input triggers both API calls, and a modal prompts the user when the profile exists on multiple platforms.

Test Case: Handle with Only Twitter Profile Exists
Input Example: x
Expected Outcome: Extracts clean handle as x. fetchTwitterProfile succeeds while fetchLinkedinProfile fails. Retrieves Twitter docId and redirects to chat without showing a modal.
Status: PASS
Comment: Verified that if only the Twitter profile is available, the process continues with Twitter exclusively and bypasses modal selection.

Test Case: Handle with Only LinkedIn Profile Exists
Input Example: nik-shevchenko-08565b18b
Expected Outcome: Extracts clean handle as nik-shevchenko-08565b18b. fetchLinkedinProfile succeeds while fetchTwitterProfile fails. Retrieves LinkedIn docId and redirects to chat without showing a modal.
Status: PASS
Comment: Verified that if only the LinkedIn profile is available, the process continues with LinkedIn exclusively and bypasses modal selection.

Test Case: Profile Already Exists in Database
Input Example: Valid handle/URL (any format)
Expected Outcome: A success toast is displayed, showing a modal or redirecting to chat.
Status: PASS
Comment: Verified that when a profile already exists in the database, a success message is shown, and the user is either redirected to chat or shown a modal.

@harshithsunku harshithsunku changed the title Initial commit For linkedin scrapping in OMI Personas linkedin scrapping for OMI Web Personas #1752 Feb 9, 2025
@harshithsunku harshithsunku changed the title linkedin scrapping for OMI Web Personas #1752 linkedin for OMI Web Personas #1752 Feb 9, 2025
@harshithsunku harshithsunku marked this pull request as ready for review February 9, 2025 16:47
@harshithsunku harshithsunku marked this pull request as draft February 9, 2025 17:27
@harshithsunku harshithsunku marked this pull request as ready for review February 9, 2025 17:54
@beastoin
Copy link
Collaborator

1/ how do you handle the profile creation / navigation when the user simply types @x then hit the create ai persona button ? consider 2 cases: one for the new user and for an existing user.

@harshithsunku

@harshithsunku
Copy link
Author

1/ how do you handle the profile creation / navigation when the user simply types @x then hit the create ai persona button ? consider 2 cases: one for the new user and for an existing user.

@harshithsunku

Hi @beastoin ,

Kindly refer to the "Flow Diagram for Profile Selection" and check the screenshot in the description above.

Thanks.

@beastoin
Copy link
Collaborator

1/ could you simplify the diagram? the complexity level of this simple task should not be that high.

man, if you are using an AI to generate the diagram for your code, you have to make sure your code is super good and backed by the diagram from your brain.

forgive me if you drew it yourself 🤯

@harshithsunku

@harshithsunku
Copy link
Author

1/ could you simplify the diagram? the complexity level of this simple task should not be that high.

man, if you are using an AI to generate the diagram for your code, you have to make sure your code is super good and backed by the diagram from your brain.

forgive me if you drew it yourself 🤯

@harshithsunku

Hi @beastoin ,

The diagram was created manually—yes, the old-fashioned way! ✍️

It was the initial design to ensure all scenarios were covered before diving into the actual code.

The final code is now sleek, simple, and handles all the scenarios from the previous flow diagram.

Kindly refer to the final code flow diagram. It’s as simple as it gets! 😃

Thanks!

@kodjima33
Copy link
Collaborator

kodjima33 commented Feb 12, 2025

@harshithsunku can you host it anywhere and give a link? i want to test scraping of posts

@harshithsunku
Copy link
Author

harshithsunku commented Feb 13, 2025

@harshithsunku can you host it anywhere and give a link? i want to test scraping of posts

Hi @kodjima33 ,

I've shared the link over a mail please check.

Thanks.

@beastoin
Copy link
Collaborator

1/ ✅ ok
2/ could you support the link as well, besides the handle. e.g https://x.com/_thinx -> X @_thinx, https://www.linkedin.com/in/thinx/ -> LinkedIn @THINX

@harshithsunku

@harshithsunku
Copy link
Author

harshithsunku commented Feb 15, 2025

1/ ✅ ok
2/ could you support the link as well, besides the handle. e.g https://x.com/_thinx -> X @_thinx, https://www.linkedin.com/in/thinx/ -> LinkedIn @THINX

@harshithsunku

Hi @beastoin , @kodjima33 .

Good suggestion! I had considered this during the initial design/implementation but didn’t add it since it wasn’t part of the original request.

I’ll include this support now.

I’m currently on a business travell and will be back on Saturday, February 22nd. I’ll get this done by February 23rd.

Thanks for your understanding!

Regards,
Harshith

@harshithsunku
Copy link
Author

1/ ✅ ok 2/ could you support the link as well, besides the handle. e.g https://x.com/_thinx -> X @_thinx, https://www.linkedin.com/in/thinx/ -> LinkedIn @THINX

@harshithsunku

Hi @beastoin, @kodjima33,

I have added support for the link as well. Kindly verify using the link shared via email.
Updated the PR with URL changes as well and UT cases in description.

Regards,
Harshith

@beastoin
Copy link
Collaborator

2/ could you improve the code quality ? these code block looks messy https://github.com/BasedHardware/omi/pull/1780/files#diff-237e4bc2a7e642164212ab39111544957f2cc77d56606e6ddc91a8f52a2d381fR150-R204 ; imaging we have instagram, threads, ..., and more.

3/ resolve conflicts pls sir.

@harshithsunku

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add linkedin for omi web personas
3 participants