Skip to content

Get Conversation (or Candidates) Messages from Specific Conversation #220

@IqroNegoro

Description

@IqroNegoro

Hi realcoloride, its been a while i haven't use the package after previous project railchat, now i want to create the same for another game.

i'm glad that the package is now more lightweight..

but it seems that the docs getting confusion when i read it (ikr cuz it still in development)

How to get conversation from the specific externalId?

heres my code:

const ai = e.context.ai as CharacterAI;
const dm = await ai.fetchCharacter(character.external_id);

const history = await dm.DM(chat.history_id);

console.log(history.messages);

and it just return:

{ '0':                                                                                                                                                   15.05.59
   { turnKey:
      { chatId: '5c17d1bb-05d1-4d32-b42f-8e565a20a931',
        turnId: 'cba7d929-6242-4a51-b709-6ae61c8b51a7' },
     turnId: 'cba7d929-6242-4a51-b709-6ae61c8b51a7',
     chatId: '5c17d1bb-05d1-4d32-b42f-8e565a20a931',
     creationDate: 2025-12-28T06:58:19.389Z,
     lastUpdateDate: 2025-12-28T06:58:19.389Z,
     authorId: 'JTYgp4_uB1WOPttH8QRB94hJ1Y61KmEKcKnfmGPBIIc',
     isHuman: false,
     authorUsername: 'Rikuhachima Aru',
     isPinned: false,
     state: 'STATE_OK' },
  '1':
   { turnKey:
      { chatId: '5c17d1bb-05d1-4d32-b42f-8e565a20a931',
        turnId: 'afa072d8-d7b9-406f-b0b2-87b09d9db519' },
     turnId: 'afa072d8-d7b9-406f-b0b2-87b09d9db519',
     chatId: '5c17d1bb-05d1-4d32-b42f-8e565a20a931',
     creationDate: 2025-12-28T07:40:42.658Z,
     lastUpdateDate: 2025-12-28T07:40:42.658Z,
     authorId: '884427616',
     isHuman: true,
     authorUsername: 'Sensei',
     isPinned: false,
     state: 'STATE_OK' },
  '2':
   { turnKey:
      { chatId: '5c17d1bb-05d1-4d32-b42f-8e565a20a931',
        turnId: 'd5059098-dbd6-4a3d-8b2d-f4545727fea0' },
     turnId: 'd5059098-dbd6-4a3d-8b2d-f4545727fea0',
     chatId: '5c17d1bb-05d1-4d32-b42f-8e565a20a931',
     creationDate: 2025-12-28T07:40:42.735Z,
     lastUpdateDate: 2025-12-28T07:40:46.161Z,
     authorId: 'JTYgp4_uB1WOPttH8QRB94hJ1Y61KmEKcKnfmGPBIIc',
     isHuman: false,
     authorUsername: 'Rikuhachima Aru',
     isPinned: false,
     state: 'STATE_OK' } }

i didnt any see content message that i want, i have see the autocomplete, and didnt see any function to get candidates messages except:

(await history.sendMessage('Hello')).primaryCandidate

but it just showing message.content right?

how i can get the conversation messages 😭

in v1, it done by this:

const historyChat = await chat.fetchHistory();

const history = historyChat.messages.map((item : any) => ({
    id: item.id,
    text: item.text,
    character: !item.srcIsHuman
}));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions