Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/diagnose-message-shape.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions scripts/diagnose-message-shape.mjs
Original file line number Diff line number Diff line change
@@ -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));
}
Loading