glitchgrab 1.62.3 → 1.62.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -319,7 +319,7 @@ const leads = await listLeads({ source: "demo", since: "2026-09-01" }); // GLITC
319
319
 
320
320
  ## How do I show customer follow-ups in my own admin?
321
321
 
322
- Glitchgrab keeps, per customer, the recorded calls, a running note history and the booked next call — and WhatsApps whoever booked it when it is due. After each call a note of what was asked and promised appears by itself, with a suggested next call. Read and write it from your server with the `ggc_` key:
322
+ Glitchgrab keeps, per customer, the recorded calls, a running note history and the booked next call — and WhatsApps whoever booked it 5 minutes before it is due. After each call a note of what was asked and promised appears by itself, and the next call is booked from what was said, with a reason. Read and write it from your server with the `ggc_` key:
323
323
 
324
324
  ```ts
325
325
  import { listFollowUps, setFollowUpBooking, dialFollowUp, addFollowUpNote } from "glitchgrab/server";
@@ -337,6 +337,21 @@ await dialFollowUp(owner.id, { operator: { email: "admin@you.in" } });
337
337
 
338
338
  The `operator` must be someone on the project's phone line in Glitchgrab. Webhooks `followup.note_added` and `followup.booking_changed` keep your list fresh without polling.
339
339
 
340
+ ### The next call, booked from the call — with why
341
+
342
+ When a call's summary is ready, Glitchgrab books the next call the customer and caller agreed on, unless a booking someone set by hand already stands (that one is never overwritten). Show `booking.reason` under "Next call":
343
+
344
+ ```ts
345
+ // Send the customer's business with the call — it is named in the reason
346
+ await dialFollowUp(owner.id, { operator: { email: "admin@you.in" }, name: "Sunita Patil", businessName: "Shanti Study Room" });
347
+
348
+ const [row] = await listFollowUps([owner.id]);
349
+ row.booking; // { at, reason: "Ravi → Sunita Patil (Shanti Study Room): set up auto-pay again", auto: true, confirmedAt: null, bookedBy: "Ravi" }
350
+ // auto → label it "Booked from the call summary"
351
+ ```
352
+
353
+ Whoever made the call gets a WhatsApp asking to keep it (Yes) or remove it (No); no answer keeps it. Moving or clearing it with `setFollowUpBooking` makes it a person's booking; send `reason` there to set your own, or leave it out to keep the current one.
354
+
340
355
  ### "Ring me on" — pick which phone rings
341
356
 
342
357
  Each person on the line keeps a list of verified phones for your project (shown read-only in Glitchgrab under Calls → Phone lines → People): one Default, the rest backups. Lists are per project — your key never sees or changes another product's. If a phone isn't picked up, busy or rejected, the next backup rings by itself.
package/dist/server.d.mts CHANGED
@@ -643,11 +643,19 @@ interface FollowUp {
643
643
  /** Digits, `91` + 10. */
644
644
  phone: string | null;
645
645
  name: string | null;
646
+ /** The customer's business (Abhyasika: the library name), as you sent it. */
647
+ businessName: string | null;
646
648
  /** ISO. The booked next call. */
647
649
  nextCallAt: string | null;
648
650
  nextCallBookedBy: string | null;
649
651
  due: FollowUpDue;
650
- /** ISO. Read from the last call's transcript — shown as a suggestion, never booked by itself. */
652
+ /** The next call with why it is happening (#670). Null when nothing is booked. */
653
+ booking: FollowUpBooking | null;
654
+ /**
655
+ * ISO. Read from the last call's transcript. Since #670 a call's suggestion
656
+ * is booked by itself (see `booking.auto`); it stays only a suggestion when
657
+ * a person's own booking already stands.
658
+ */
651
659
  suggestedNextCallAt: string | null;
652
660
  suggestedNextCallReason: string | null;
653
661
  lastNote: string | null;
@@ -665,6 +673,19 @@ interface FollowUp {
665
673
  ringingPhone: string | null;
666
674
  } | null;
667
675
  }
676
+ interface FollowUpBooking {
677
+ /** ISO. */
678
+ at: string;
679
+ /** "Ravi → Sunita Patil (Shanti Study Room): set up auto-pay again" — show it under "Next call". */
680
+ reason: string | null;
681
+ /** Booked by Glitchgrab from the call summary — label it "Booked from the call summary". */
682
+ auto: boolean;
683
+ /** ISO. The caller tapped "Yes, keep it" on WhatsApp. */
684
+ confirmedAt: string | null;
685
+ /** The "keep this call?" WhatsApp reached whoever made the call. */
686
+ askedOnWhatsApp: boolean;
687
+ bookedBy: string | null;
688
+ }
668
689
  interface FollowUpNote {
669
690
  id: string;
670
691
  body: string;
@@ -753,26 +774,35 @@ declare function addFollowUpNote(externalId: string, note: {
753
774
  author?: string;
754
775
  phone?: string;
755
776
  name?: string;
777
+ businessName?: string;
756
778
  }, options?: CallsOptions): Promise<FollowUpWriteResult<{
757
779
  id: string;
758
780
  }>>;
759
781
  /**
760
782
  * Book, move (`Date`/ISO) or clear (`null`) the next call. The reminder
761
- * WhatsApp goes to `operator`, else the project owner. Never throws.
783
+ * WhatsApp goes to `operator`, else the project owner. `reason` is read back
784
+ * as `booking.reason`; left out, a moved booking keeps its reason. A booking
785
+ * made here is never replaced by the next call's automatic one. Never throws.
762
786
  */
763
787
  declare function setFollowUpBooking(externalId: string, booking: {
764
788
  nextCallAt: Date | string | null;
789
+ reason?: string | null;
765
790
  operator?: FollowUpOperator;
766
791
  author?: string;
767
792
  phone?: string;
768
793
  name?: string;
794
+ businessName?: string;
769
795
  }, options?: CallsOptions): Promise<FollowUpWriteResult<{
770
796
  nextCallAt: string | null;
797
+ reason: string | null;
771
798
  }>>;
772
799
  /**
773
800
  * Start a recorded call: Glitchgrab rings `operator`'s phone, then the
774
- * customer, from the project's line. The operator must be on that line. A note
775
- * and a suggested next call follow once the call is transcribed. Never throws.
801
+ * customer, from the project's line. The operator must be on that line. Once
802
+ * the call is transcribed a note is written and the next call is booked from
803
+ * it with a reason (#670) — unless a person's booking already stands — and the
804
+ * operator is asked on WhatsApp to keep or remove it. `businessName` (the
805
+ * customer's business) is named in that reason. Never throws.
776
806
  *
777
807
  * `ringPhone` picks which of the operator's verified phones rings first (list
778
808
  * them with {@link getOperatorRingNumbers}); omitted = their Default. If that
@@ -787,6 +817,7 @@ declare function dialFollowUp(externalId: string, call: {
787
817
  phone?: string;
788
818
  toPhone?: string;
789
819
  name?: string;
820
+ businessName?: string;
790
821
  lineId?: string;
791
822
  ringPhone?: string;
792
823
  }, options?: CallsOptions): Promise<FollowUpWriteResult<{
@@ -929,4 +960,4 @@ declare function testRingNumber(id: string, options?: CallsOptions): Promise<Rin
929
960
  verified: boolean;
930
961
  }>>;
931
962
 
932
- export { type Booking, type BookingAnswer, type BookingClientNotice, type BookingMutationResult, type BookingNotifyRecipient, type BookingQuestion, type BookingQuestionInput, type BookingSettings, type BookingSettingsChanges, type BookingSettingsResult, type BookingSettingsState, type BookingWorkingHours, type Call, type CallAudio, type CallListItem, type CallMoment, type CallParticipant, type CallsOptions, type CaptureServerErrorsOptions, type DeleteCallResult, type FollowUp, type FollowUpCall, type FollowUpDetail, type FollowUpDue, type FollowUpNote, type FollowUpOperator, type FollowUpWriteResult, type GetCallOptions, type Guide, type GuideReadOptions, type GuideSummary, type Lead, type LineCallerResult, type ListBookingsOptions, type ListCallsOptions, type ListLeadsOptions, type OperatorRingNumber, type OperatorRingNumbersResult, ReportResult, ReportSeverity, ReportType, type RingErrorCode, type RingNumber, type RingNumberList, type RingNumberWriteResult, type ServerReportOptions, type ServerReporterConfig, type ServerReporterIdentity, type SignSessionOptions, addFollowUpNote, addLineCaller, addRingNumber, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, dialFollowUp, discardBookingQuestionsDraft, escapeJsonForScript, getBookingSettings, getCall, getFollowUp, getGuide, getOperatorRingNumbers, listBookings, listCalls, listFollowUps, listGuides, listLeads, listRingNumbers, publishBookingQuestions, removeLineCaller, removeRingNumber, reportServerError, rescheduleBooking, resetServerReporter, setFollowUpBooking, signSession, testRingNumber, updateBookingSettings, updateRingNumber };
963
+ export { type Booking, type BookingAnswer, type BookingClientNotice, type BookingMutationResult, type BookingNotifyRecipient, type BookingQuestion, type BookingQuestionInput, type BookingSettings, type BookingSettingsChanges, type BookingSettingsResult, type BookingSettingsState, type BookingWorkingHours, type Call, type CallAudio, type CallListItem, type CallMoment, type CallParticipant, type CallsOptions, type CaptureServerErrorsOptions, type DeleteCallResult, type FollowUp, type FollowUpBooking, type FollowUpCall, type FollowUpDetail, type FollowUpDue, type FollowUpNote, type FollowUpOperator, type FollowUpWriteResult, type GetCallOptions, type Guide, type GuideReadOptions, type GuideSummary, type Lead, type LineCallerResult, type ListBookingsOptions, type ListCallsOptions, type ListLeadsOptions, type OperatorRingNumber, type OperatorRingNumbersResult, ReportResult, ReportSeverity, ReportType, type RingErrorCode, type RingNumber, type RingNumberList, type RingNumberWriteResult, type ServerReportOptions, type ServerReporterConfig, type ServerReporterIdentity, type SignSessionOptions, addFollowUpNote, addLineCaller, addRingNumber, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, dialFollowUp, discardBookingQuestionsDraft, escapeJsonForScript, getBookingSettings, getCall, getFollowUp, getGuide, getOperatorRingNumbers, listBookings, listCalls, listFollowUps, listGuides, listLeads, listRingNumbers, publishBookingQuestions, removeLineCaller, removeRingNumber, reportServerError, rescheduleBooking, resetServerReporter, setFollowUpBooking, signSession, testRingNumber, updateBookingSettings, updateRingNumber };
package/dist/server.d.ts CHANGED
@@ -643,11 +643,19 @@ interface FollowUp {
643
643
  /** Digits, `91` + 10. */
644
644
  phone: string | null;
645
645
  name: string | null;
646
+ /** The customer's business (Abhyasika: the library name), as you sent it. */
647
+ businessName: string | null;
646
648
  /** ISO. The booked next call. */
647
649
  nextCallAt: string | null;
648
650
  nextCallBookedBy: string | null;
649
651
  due: FollowUpDue;
650
- /** ISO. Read from the last call's transcript — shown as a suggestion, never booked by itself. */
652
+ /** The next call with why it is happening (#670). Null when nothing is booked. */
653
+ booking: FollowUpBooking | null;
654
+ /**
655
+ * ISO. Read from the last call's transcript. Since #670 a call's suggestion
656
+ * is booked by itself (see `booking.auto`); it stays only a suggestion when
657
+ * a person's own booking already stands.
658
+ */
651
659
  suggestedNextCallAt: string | null;
652
660
  suggestedNextCallReason: string | null;
653
661
  lastNote: string | null;
@@ -665,6 +673,19 @@ interface FollowUp {
665
673
  ringingPhone: string | null;
666
674
  } | null;
667
675
  }
676
+ interface FollowUpBooking {
677
+ /** ISO. */
678
+ at: string;
679
+ /** "Ravi → Sunita Patil (Shanti Study Room): set up auto-pay again" — show it under "Next call". */
680
+ reason: string | null;
681
+ /** Booked by Glitchgrab from the call summary — label it "Booked from the call summary". */
682
+ auto: boolean;
683
+ /** ISO. The caller tapped "Yes, keep it" on WhatsApp. */
684
+ confirmedAt: string | null;
685
+ /** The "keep this call?" WhatsApp reached whoever made the call. */
686
+ askedOnWhatsApp: boolean;
687
+ bookedBy: string | null;
688
+ }
668
689
  interface FollowUpNote {
669
690
  id: string;
670
691
  body: string;
@@ -753,26 +774,35 @@ declare function addFollowUpNote(externalId: string, note: {
753
774
  author?: string;
754
775
  phone?: string;
755
776
  name?: string;
777
+ businessName?: string;
756
778
  }, options?: CallsOptions): Promise<FollowUpWriteResult<{
757
779
  id: string;
758
780
  }>>;
759
781
  /**
760
782
  * Book, move (`Date`/ISO) or clear (`null`) the next call. The reminder
761
- * WhatsApp goes to `operator`, else the project owner. Never throws.
783
+ * WhatsApp goes to `operator`, else the project owner. `reason` is read back
784
+ * as `booking.reason`; left out, a moved booking keeps its reason. A booking
785
+ * made here is never replaced by the next call's automatic one. Never throws.
762
786
  */
763
787
  declare function setFollowUpBooking(externalId: string, booking: {
764
788
  nextCallAt: Date | string | null;
789
+ reason?: string | null;
765
790
  operator?: FollowUpOperator;
766
791
  author?: string;
767
792
  phone?: string;
768
793
  name?: string;
794
+ businessName?: string;
769
795
  }, options?: CallsOptions): Promise<FollowUpWriteResult<{
770
796
  nextCallAt: string | null;
797
+ reason: string | null;
771
798
  }>>;
772
799
  /**
773
800
  * Start a recorded call: Glitchgrab rings `operator`'s phone, then the
774
- * customer, from the project's line. The operator must be on that line. A note
775
- * and a suggested next call follow once the call is transcribed. Never throws.
801
+ * customer, from the project's line. The operator must be on that line. Once
802
+ * the call is transcribed a note is written and the next call is booked from
803
+ * it with a reason (#670) — unless a person's booking already stands — and the
804
+ * operator is asked on WhatsApp to keep or remove it. `businessName` (the
805
+ * customer's business) is named in that reason. Never throws.
776
806
  *
777
807
  * `ringPhone` picks which of the operator's verified phones rings first (list
778
808
  * them with {@link getOperatorRingNumbers}); omitted = their Default. If that
@@ -787,6 +817,7 @@ declare function dialFollowUp(externalId: string, call: {
787
817
  phone?: string;
788
818
  toPhone?: string;
789
819
  name?: string;
820
+ businessName?: string;
790
821
  lineId?: string;
791
822
  ringPhone?: string;
792
823
  }, options?: CallsOptions): Promise<FollowUpWriteResult<{
@@ -929,4 +960,4 @@ declare function testRingNumber(id: string, options?: CallsOptions): Promise<Rin
929
960
  verified: boolean;
930
961
  }>>;
931
962
 
932
- export { type Booking, type BookingAnswer, type BookingClientNotice, type BookingMutationResult, type BookingNotifyRecipient, type BookingQuestion, type BookingQuestionInput, type BookingSettings, type BookingSettingsChanges, type BookingSettingsResult, type BookingSettingsState, type BookingWorkingHours, type Call, type CallAudio, type CallListItem, type CallMoment, type CallParticipant, type CallsOptions, type CaptureServerErrorsOptions, type DeleteCallResult, type FollowUp, type FollowUpCall, type FollowUpDetail, type FollowUpDue, type FollowUpNote, type FollowUpOperator, type FollowUpWriteResult, type GetCallOptions, type Guide, type GuideReadOptions, type GuideSummary, type Lead, type LineCallerResult, type ListBookingsOptions, type ListCallsOptions, type ListLeadsOptions, type OperatorRingNumber, type OperatorRingNumbersResult, ReportResult, ReportSeverity, ReportType, type RingErrorCode, type RingNumber, type RingNumberList, type RingNumberWriteResult, type ServerReportOptions, type ServerReporterConfig, type ServerReporterIdentity, type SignSessionOptions, addFollowUpNote, addLineCaller, addRingNumber, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, dialFollowUp, discardBookingQuestionsDraft, escapeJsonForScript, getBookingSettings, getCall, getFollowUp, getGuide, getOperatorRingNumbers, listBookings, listCalls, listFollowUps, listGuides, listLeads, listRingNumbers, publishBookingQuestions, removeLineCaller, removeRingNumber, reportServerError, rescheduleBooking, resetServerReporter, setFollowUpBooking, signSession, testRingNumber, updateBookingSettings, updateRingNumber };
963
+ export { type Booking, type BookingAnswer, type BookingClientNotice, type BookingMutationResult, type BookingNotifyRecipient, type BookingQuestion, type BookingQuestionInput, type BookingSettings, type BookingSettingsChanges, type BookingSettingsResult, type BookingSettingsState, type BookingWorkingHours, type Call, type CallAudio, type CallListItem, type CallMoment, type CallParticipant, type CallsOptions, type CaptureServerErrorsOptions, type DeleteCallResult, type FollowUp, type FollowUpBooking, type FollowUpCall, type FollowUpDetail, type FollowUpDue, type FollowUpNote, type FollowUpOperator, type FollowUpWriteResult, type GetCallOptions, type Guide, type GuideReadOptions, type GuideSummary, type Lead, type LineCallerResult, type ListBookingsOptions, type ListCallsOptions, type ListLeadsOptions, type OperatorRingNumber, type OperatorRingNumbersResult, ReportResult, ReportSeverity, ReportType, type RingErrorCode, type RingNumber, type RingNumberList, type RingNumberWriteResult, type ServerReportOptions, type ServerReporterConfig, type ServerReporterIdentity, type SignSessionOptions, addFollowUpNote, addLineCaller, addRingNumber, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, dialFollowUp, discardBookingQuestionsDraft, escapeJsonForScript, getBookingSettings, getCall, getFollowUp, getGuide, getOperatorRingNumbers, listBookings, listCalls, listFollowUps, listGuides, listLeads, listRingNumbers, publishBookingQuestions, removeLineCaller, removeRingNumber, reportServerError, rescheduleBooking, resetServerReporter, setFollowUpBooking, signSession, testRingNumber, updateBookingSettings, updateRingNumber };
package/dist/server.js CHANGED
@@ -744,9 +744,18 @@ function readFollowUp(value) {
744
744
  externalId: stringOrNull(value.externalId),
745
745
  phone: stringOrNull(value.phone),
746
746
  name: stringOrNull(value.name),
747
+ businessName: stringOrNull(value.businessName),
747
748
  nextCallAt: stringOrNull(value.nextCallAt),
748
749
  nextCallBookedBy: stringOrNull(value.nextCallBookedBy),
749
750
  due: typeof value.due === "string" && DUES.has(value.due) ? value.due : "none",
751
+ booking: isRecord(value.booking) && typeof value.booking.at === "string" ? {
752
+ at: value.booking.at,
753
+ reason: stringOrNull(value.booking.reason),
754
+ auto: value.booking.auto === true,
755
+ confirmedAt: stringOrNull(value.booking.confirmedAt),
756
+ askedOnWhatsApp: value.booking.askedOnWhatsApp === true,
757
+ bookedBy: stringOrNull(value.booking.bookedBy)
758
+ } : null,
750
759
  suggestedNextCallAt: stringOrNull(value.suggestedNextCallAt),
751
760
  suggestedNextCallReason: stringOrNull(value.suggestedNextCallReason),
752
761
  lastNote: stringOrNull(value.lastNote),
@@ -854,7 +863,8 @@ function addFollowUpNote(externalId, note, options = {}) {
854
863
  function setFollowUpBooking(externalId, booking, options = {}) {
855
864
  const at = booking.nextCallAt instanceof Date ? booking.nextCallAt.toISOString() : booking.nextCallAt;
856
865
  return writeFollowUp(followUpPath(externalId, "/booking"), "PUT", { ...booking, nextCallAt: at }, options, (d) => ({
857
- nextCallAt: stringOrNull(d.nextCallAt)
866
+ nextCallAt: stringOrNull(d.nextCallAt),
867
+ reason: stringOrNull(d.reason)
858
868
  }));
859
869
  }
860
870
  function dialFollowUp(externalId, call, options = {}) {