Menu

#156 [feature] Sending and receiving live status

closed
nobody
2025-11-18
2025-10-13
Anonymous
No

Originally created by: supreme-gg-gg
Originally owned by: I3run0

Is your feature request related to a problem? Please describe.
On real web and mobile client you send status like online, typing, etc. This can be easily done now because we already are using the exact same realtime protocol.

Optionally, also receive, parse, and handle live status from the chat. See below for more info.

Describe the solution you'd like

  • Config for whether to send live status
  • If yes, send status for typing, online, etc

Optionally, handle events indicating if the other participant(s) is/are online / read / typing etc and update the UI to show them. Create types for these events.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Sample code available in instagram_mqtt repo see here for example

Along these lines:

await ig.realtime.direct?.indicateActivity({threadId: threadId, isActive: true,});
await ig.realtime.direct?.indicateActivity({threadId: threadId, isActive: false,});
await ig.realtime.direct?.markAsSeen({threadId: threadId, itemId: args[1],});

For parsing activity indicators received, you will need to dig a bit into the raw response from the MQTT client yourself, for example, these messages (message, direct, and realtime events) seem relevant. Would appreciate if you comment your investigation result here and tag me if you choose to work on this optional feature as well. You can get these results by running the linked sample code above and trying to receive messages on the logged in client.

messageWrapper {
  event: 'patch',
  message_type: 1,
  seq_id: 7563,
  tq_seq_id: 2668,
  mi_trace_id: -3098480666398099500,
  mutation_token: '7383277393301353020',
  client_context: '7383277393301353020',
  realtime: true,
  delta_type: 'deltaReadReceipt',
  message: {
    path: '/direct_v2/threads/340282366841710301281161041946425021802/participants/23684901355/has_seen',
    op: 'replace',
    thread_id: '340282366841710301281161041946425021802',
    item_id: '32471997368711323054250727382712320',
    client_context: '7383277393301353020',
    timestamp: 1760310505223000,
    created_at: 1760310504605020,
    shh_seen_state: {},
    disappearing_messages_seen_state: {}
  }
}
realtimeSub {
  data: {
    message: {
      topic: 'direct',
      payload: '{"event":"patch","data":[{"op":"add","path":"/direct_v2/threads/340282366841710301281161041946425021802/activity_indicator_id/d33ab33c-75a1-4f2a-9e1c-71498fd67695","value":"{\\"timestamp\\":1760310530166604,\\"sender_id\\":23684901355,\\"ttl\\":22000,\\"activity_status\\":1,\\"attribution\\":null}"}]}',
      json: [Object]
    }
  },
  topic: {
    id: '149',
    path: '/ig_realtime_sub',
    parser: GraphqlParser {},
    noParse: true
  }
}
direct {
  op: 'add',
  path: '/direct_v2/threads/340282366841710301281161041946425021802/activity_indicator_id/d33ab33c-75a1-4f2a-9e1c-71498fd67695',
  value: {
    timestamp: 1760310530166604,
    sender_id: 23684901355,
    ttl: 22000,
    activity_status: 1,
    attribution: null
  }
}

This can be easily done but we hope to leave some low hanging fruits for contributors 😄

Related

Tickets: #153
Tickets: #166
Tickets: #167
Tickets: #178

Discussion

  • Anonymous

    Anonymous - 2025-10-22

    Originally posted by: I3run0

    Hi, I am a noob. But I liked the project. I will try it

     
  • Anonymous

    Anonymous - 2025-10-23

    Originally posted by: supreme-gg-gg

    Sure, let us know if you need help! Right now we send online status by default (so if you try with your other account you can see it shown as online), but we don't have a config for this and we also don't support mark as seen or typing I believe. Requires a bit of experimentation first, would appreciate if you update us on what needs to be added and a rough plan before PR.

     
  • Anonymous

    Anonymous - 2025-10-23
     
  • Anonymous

    Anonymous - 2025-10-24

    Originally posted by: I3run0

    Hi @supreme-gg-gg , I am facing the following issue when I am trying to log in instagram-ts following the current CONTRIBUTING guide:

     node_modules/ink/build/reconciler.js:136:19
    
     133:     },
     134:     createTextInstance(text, _root, hostContext) {
     135:         if (!hostContext.isInsideText) {
     136:             throw new Error(`Text string "${text}" must be rendered inside <Text> component`);
     137:         }
     138:         return createTextNode(text);
     139:     },
    
    
     - createTextInstance (node_modules/ink/build/reconciler.js:136:19)
     - completeWork (node_modules/react-reconciler/cjs/react-reconciler.development.js:9082:42)
     - runWithFiberInDEV (node_modules/react-reconciler/cjs/react-reconciler.development.js:1735:30)
     - completeUnitOfWork (node_modules/react-reconciler/cjs/react-reconciler.development.js:12962:19)
     - performUnitOfWork (node_modules/react-reconciler/cjs/react-reconciler.development.js:12843:11)
     - workLoopSync (node_modules/react-reconciler/cjs/react-reconciler.development.js:12644:41)
     - renderRootSync (node_modules/react-reconciler/cjs/react-reconciler.development.js:12624:11)
     - performWorkOnRoot (node_modules/react-reconciler/cjs/react-reconciler.development.js:12135:44)
     -performWorkOnRootViaSchedulerTask
                                       (node_modules/react-reconciler/cjs/react-reconciler.development.js:2431:7)
    
    
     - Immediate.performWorkUntilDeadline (node_modules/scheduler/cjs/scheduler.development.js:45:48)
     - process.processImmediate (node:internal/timers:505:21)
    
     
  • Anonymous

    Anonymous - 2025-10-24

    Originally posted by: supreme-gg-gg

    Hi @supreme-gg-gg , I am facing the following issue when I am trying to log in instagram-ts following the current CONTRIBUTING guide:

    ```
    node_modules/ink/build/reconciler.js:136:19

    133: },
    134: createTextInstance(text, _root, hostContext) {
    135: if (!hostContext.isInsideText) {
    136: throw new Error(Text string "${text}" must be rendered inside <Text> component);
    137: }
    138: return createTextNode(text);
    139: },

    • createTextInstance (node_modules/ink/build/reconciler.js:136:19)
    • completeWork (node_modules/react-reconciler/cjs/react-reconciler.development.js:9082:42)
    • runWithFiberInDEV (node_modules/react-reconciler/cjs/react-reconciler.development.js:1735:30)
    • completeUnitOfWork (node_modules/react-reconciler/cjs/react-reconciler.development.js:12962:19)
    • performUnitOfWork (node_modules/react-reconciler/cjs/react-reconciler.development.js:12843:11)
    • workLoopSync (node_modules/react-reconciler/cjs/react-reconciler.development.js:12644:41)
    • renderRootSync (node_modules/react-reconciler/cjs/react-reconciler.development.js:12624:11)
    • performWorkOnRoot (node_modules/react-reconciler/cjs/react-reconciler.development.js:12135:44)
      -performWorkOnRootViaSchedulerTask
      (node_modules/react-reconciler/cjs/react-reconciler.development.js:2431:7)

    • Immediate.performWorkUntilDeadline (node_modules/scheduler/cjs/scheduler.development.js:45:48)

    • process.processImmediate (node:internal/timers:505:21)
      ```

    Are you using 2FA? I just noticed this issue a bit earlier will try to fix it asap, can you send over the logs in .instagram-cli/logs if it's there?

     
  • Anonymous

    Anonymous - 2025-10-24

    Originally posted by: I3run0

    I don't have 2FA. Following is the log of the last session:

     2025-10-24T22:45:23.727Z ERROR [InstagramClient]: Login failed
    IgLoginBadPasswordError: POST /api/v1/accounts/login/ - 400 Bad Request; We can send you an email to help you get back into your account.
        at /home/hilb/git/instagram-cli/instagram-ts/node_modules/instagram-private-api/dist/repositories/account.repository.js:40:27
        at tryCatcher (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/util.js:16:23)
        at /home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/catch_filter.js:17:41
        at tryCatcher (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/util.js:16:23)
        at Promise._settlePromiseFromHandler (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/promise.js:547:31)
        at Promise._settlePromise (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/promise.js:604:18)
        at Promise._settlePromise0 (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/promise.js:649:10)
        at Promise._settlePromises (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/promise.js:725:18)
        at _drainQueueStep (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/async.js:93:12)
        at _drainQueue (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/async.js:86:9)
        at Async._drainQueues (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/async.js:102:5)
        at Async.drainQueues (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/async.js:15:14)
        at process.processImmediate (node:internal/timers:505:21)
    
     
  • Anonymous

    Anonymous - 2025-10-25

    Originally posted by: supreme-gg-gg

    I don't have 2FA. Following is the log of the last session:

    2025-10-24T22:45:23.727Z ERROR [InstagramClient]: Login failed IgLoginBadPasswordError: POST /api/v1/accounts/login/ - 400 Bad Request; We can send you an email to help you get back into your account. at /home/hilb/git/instagram-cli/instagram-ts/node_modules/instagram-private-api/dist/repositories/account.repository.js:40:27 at tryCatcher (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/util.js:16:23) at /home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/catch_filter.js:17:41 at tryCatcher (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/promise.js:725:18) at _drainQueueStep (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/async.js:102:5) at Async.drainQueues (/home/hilb/git/instagram-cli/instagram-ts/node_modules/bluebird/js/release/async.js:15:14) at process.processImmediate (node:internal/timers:505:21)

    This API error message is usually when you entered the wrong password. The previous error with react happens since we had a typo in code (will fix that asap), but it is not relevant to the login API error, it only crashes when the CLI tries to display the login error message which is in the logs. Can you try again make sure you have the correct password? I faced this issue before but I realised I made a typo in password lol

     
  • Anonymous

    Anonymous - 2025-10-25

    Originally posted by: I3run0

    Nice, Everthing works well now. I was just using the wrong password, lol. Thank you @supreme-gg-gg

     
  • Anonymous

    Anonymous - 2025-10-26

    Originally posted by: I3run0

    Hi,
    I’m trying to retrieve the status of another instagram user in a thread (e.g., typing, online).

    For the “typing” event, I noticed that we can parse the “direct” event to receive something like the following, and interpret events in “direct” with the op: add operation as typing:

    {
       "op":"add",
       "path":"/direct_v2/threads/340282366841710301244260048876387769597/activity_indicator_id/9a9d194c-d5fb-4500-8ffa-01e80c654851",
       "value":{
          "timestamp":1761492135782639,
          "sender_id":8284531494,
          "ttl":22000,
          "activity_status":1,
          "attribution":null
       }
    }
    

    However, I haven’t been able to figure out how to determine when the other user is online or offline. Do you have any tips or suggestions for that?

     
  • Anonymous

    Anonymous - 2025-10-26

    Originally posted by: endernoke

    Hi, I’m trying to retrieve the status of another instagram user in a thread (e.g., typing, online).

    For the “typing” event, I noticed that we can parse the “direct” event to receive something like the following, and interpret events in “direct” with the op: add operation as typing:

    { "op":"add", "path":"/direct_v2/threads/340282366841710301244260048876387769597/activity_indicator_id/9a9d194c-d5fb-4500-8ffa-01e80c654851", "value":{ "timestamp":1761492135782639, "sender_id":8284531494, "ttl":22000, "activity_status":1, "attribution":null } }

    However, I haven’t been able to figure out how to determine when the other user is online or offline. Do you have any tips or suggestions for that?

    Great find!

    Have you tried subscribing to appPresence and see if any related event is received?

     
  • Anonymous

    Anonymous - 2025-10-26

    Originally posted by: I3run0

    I tried listening to the following event types, but during testing, I wasn’t able to see any related logs.

    this.realtime.on('appPresence', (wrapper: any) => {
        this.logger.debug(`appPresence MQTT "message": ${JSON.stringify(wrapper)}`);
    });
    
    this.realtime.on('liveTypingIndicator', (wrapper: any) => {
        this.logger.debug(`liveTypingIndicator MQTT "message": ${JSON.stringify(wrapper)}`);
    });
    
    
    this.realtime.on('directTyping', (wrapper: any) => {
        this.logger.info(`liveTypingIndicator MQTT "message": ${JSON.stringify(wrapper)}`);
    });
    
     
  • Anonymous

    Anonymous - 2025-10-26

    Originally posted by: supreme-gg-gg

    I tried listening to the following event types, but during testing, I wasn’t able to see any related logs.

    `` this.realtime.on('appPresence', (wrapper: any) => { this.logger.debug(appPresence MQTT "message": ${JSON.stringify(wrapper)}`);
    });

    this.realtime.on('liveTypingIndicator', (wrapper: any) => {
    this.logger.debug(liveTypingIndicator MQTT "message": ${JSON.stringify(wrapper)});
    });

    this.realtime.on('directTyping', (wrapper: any) => {
    this.logger.info(liveTypingIndicator MQTT "message": ${JSON.stringify(wrapper)});
    });
    ```

    I don't think the three types you're trying to subscribe exist, check the RealtimeClientEvents class:

    export type RealtimeClientEvents = MergedRealtimeSubPayloads & {
        error: Error;
        warning: Error;
        receive: ReceiveEvent<unknown>;
        receiveRaw: MqttMessage;
        close: [];
        disconnect: [];
        realtimeSub: ParsedMessage<GraphQlMessage>;
        direct: RealtimeSubDirectDataWrapper;
        iris: Partial<IrisParserData>;
        message: MessageSyncMessageWrapper;
        threadUpdate: ThreadUpdateWrapper;
        clientConfigUpdate: {
            client_config_update_event: {
                publish_id: string;
                client_config_name: string;
                backing: 'QE' | string;
                client_subscription_id: '17849856529644700' | string;
            };
        };
    };
    

    I wasn't able to find a direct way to get user live status as well, @endernoke do you know any method otherwise we can just implement typing status + read / unread messages. But i think this is probably broadcasted by Instagram, it's just that both the direct and realtimSub events don't forward it. You can look into raw MqttMessage if you want perhaps, but it might get complicated

    Woudl also be nice if you can figure out a way to detect if a thread is not read and set the unread field properly, currently in client.getThreads we use thread.has_newer but it doesn't seem to be reliable. Perhaps last_seen_at vs last_activity_at comparision will suffice, you can give it a try! You can find these attributes on the DirectInboxFeedResponseThreadsItem class used by that method.

     
  • Anonymous

    Anonymous - 2025-11-18

    Ticket changed by: endernoke

    • status: open --> closed
     

Log in to post a comment.

Monday.com Logo