diff --git a/.github/workflows/diagnose-message-shape.yml b/.github/workflows/diagnose-message-shape.yml new file mode 100644 index 0000000..db118c2 --- /dev/null +++ b/.github/workflows/diagnose-message-shape.yml @@ -0,0 +1,20 @@ +name: Diagnose message shape + +on: + workflow_dispatch: + +jobs: + diagnose: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: "20" + - run: npm install + - name: Diagnose + env: + CRISP_USER_REGISTRATION_IDENTIFIER: ${{ secrets.CRISP_USER_REGISTRATION_IDENTIFIER }} + CRISP_USER_REGISTRATION_KEY: ${{ secrets.CRISP_USER_REGISTRATION_KEY }} + CRISP_USER_REGISTRATION_WEBSITE_ID: ${{ vars.CRISP_USER_REGISTRATION_WEBSITE_ID }} + run: node scripts/diagnose-message-shape.mjs diff --git a/scripts/diagnose-message-shape.mjs b/scripts/diagnose-message-shape.mjs new file mode 100644 index 0000000..0da83d3 --- /dev/null +++ b/scripts/diagnose-message-shape.mjs @@ -0,0 +1,14 @@ +#!/usr/bin/env node +import { fetchRawMessages, credsForAccount, fetchResolvedConversationsSince } from "./crisp-client.mjs"; + +const creds = credsForAccount("USER_REGISTRATION"); +const since = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString(); +const conversations = await fetchResolvedConversationsSince(creds, since); +console.log(`found ${conversations.length} resolved conversations`); +if (conversations.length > 0) { + const messages = await fetchRawMessages(creds, conversations[0].session_id); + console.log(JSON.stringify(messages[0], null, 2)); + console.log("--- conversation object keys ---"); + console.log(JSON.stringify(Object.keys(conversations[0]))); + console.log(JSON.stringify(conversations[0], null, 2)); +}