getricky 0.1.7 → 0.1.9

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.
@@ -150,7 +150,7 @@ export class RickyApi extends HeyApiClient {
150
150
  /**
151
151
  * List conversations
152
152
  *
153
- * Latest activity first.
153
+ * Latest activity first. The filters are the inbox's and combine with each other; send the same ones with `cursor`.
154
154
  *
155
155
  * Scope: `conversations:read`.
156
156
  */
@@ -1225,6 +1225,21 @@ export class RickyApi extends HeyApiClient {
1225
1225
  }
1226
1226
  });
1227
1227
  }
1228
+ /**
1229
+ * Mark a conversation unread
1230
+ *
1231
+ * Marks it unread for the whole team, as the inbox does. The contact sees nothing. Send no body.
1232
+ *
1233
+ * Scope: `conversations:write`.
1234
+ */
1235
+ markConversationUnread(options) {
1236
+ return (options.client ?? this.client).delete({
1237
+ responseStyle: 'data',
1238
+ security: [{ scheme: 'bearer', type: 'http' }],
1239
+ url: '/conversations/{conversation_id}/read',
1240
+ ...options
1241
+ });
1242
+ }
1228
1243
  /**
1229
1244
  * Mark a conversation read
1230
1245
  *
@@ -1549,4 +1564,57 @@ export class RickyApi extends HeyApiClient {
1549
1564
  ...options
1550
1565
  });
1551
1566
  }
1567
+ /**
1568
+ * Assign many conversations
1569
+ *
1570
+ * Makes members responsible for up to 100 conversations, as assigning each one does, and answers one result per conversation, in order. Each member also becomes the contact's owner. A member outside the organization refuses the whole request before any conversation changes.
1571
+ *
1572
+ * Scope: `conversations:write`.
1573
+ */
1574
+ assignConversations(options) {
1575
+ return (options.client ?? this.client).post({
1576
+ responseStyle: 'data',
1577
+ security: [{ scheme: 'bearer', type: 'http' }],
1578
+ url: '/conversations/assignments',
1579
+ ...options,
1580
+ headers: {
1581
+ 'Content-Type': 'application/json',
1582
+ ...options.headers
1583
+ }
1584
+ });
1585
+ }
1586
+ /**
1587
+ * Resolve a handoff
1588
+ *
1589
+ * Ends the conversation's `active_handoff` as the inbox does: back to the AI agent that asked for it, or with the member. A conversation with no handoff waiting answers `422 rule_violation`, and so does `returned_to_ai` when no AI agent asked for it.
1590
+ *
1591
+ * Scope: `conversations:write`.
1592
+ */
1593
+ resolveConversationHandoff(options) {
1594
+ return (options.client ?? this.client).post({
1595
+ responseStyle: 'data',
1596
+ security: [{ scheme: 'bearer', type: 'http' }],
1597
+ url: '/conversations/{conversation_id}/handoff/resolve',
1598
+ ...options,
1599
+ headers: {
1600
+ 'Content-Type': 'application/json',
1601
+ ...options.headers
1602
+ }
1603
+ });
1604
+ }
1605
+ /**
1606
+ * Fetch a message's file
1607
+ *
1608
+ * Ricky stores the file of each message it receives in the background, and `media.url` is null until it has. This stores it now from the provider and answers the message with its `url`; a file already stored answers at once. A message without a received file, or whose file the provider says expired (it keeps them about 30 days), answers `422 rule_violation`; other provider failures answer `502 upstream_error`. Send no body.
1609
+ *
1610
+ * Scope: `conversations:read`.
1611
+ */
1612
+ fetchMessageMedia(options) {
1613
+ return (options.client ?? this.client).post({
1614
+ responseStyle: 'data',
1615
+ security: [{ scheme: 'bearer', type: 'http' }],
1616
+ url: '/conversations/{conversation_id}/messages/{message_id}/media',
1617
+ ...options
1618
+ });
1619
+ }
1552
1620
  }
@@ -330,6 +330,36 @@ export type Channel = {
330
330
  */
331
331
  connected_at: string | null;
332
332
  };
333
+ /**
334
+ * A request for a person to take over from the AI agent, not resolved yet.
335
+ */
336
+ export type ConversationHandoff = {
337
+ /**
338
+ * Handoff ID.
339
+ */
340
+ id: string;
341
+ /**
342
+ * `requested` until a member takes it; `assigned` once someone is responsible.
343
+ */
344
+ status: 'requested' | 'assigned';
345
+ /**
346
+ * Whether the AI agent or a member asked for it.
347
+ */
348
+ requested_by: 'agent' | 'operator';
349
+ /**
350
+ * Why the conversation needs a person.
351
+ */
352
+ reason: 'customer_requested' | 'low_confidence' | 'manual_takeover' | 'out_of_scope' | 'sensitive' | 'other';
353
+ /**
354
+ * What the person taking over needs to know.
355
+ */
356
+ summary: string;
357
+ assigned_user_id: string | null;
358
+ /**
359
+ * When it was requested.
360
+ */
361
+ requested_at: string;
362
+ };
333
363
  /**
334
364
  * One contact talking to the organization on one channel.
335
365
  */
@@ -387,6 +417,14 @@ export type Conversation = {
387
417
  * Text of the latest message.
388
418
  */
389
419
  last_activity_preview: string | null;
420
+ /**
421
+ * Whether it has messages the team has not read.
422
+ */
423
+ unread: boolean;
424
+ /**
425
+ * The handoff to a person waiting to be resolved; null when there is none.
426
+ */
427
+ active_handoff: ConversationHandoff | null;
390
428
  };
391
429
  /**
392
430
  * One message in a conversation.
@@ -912,6 +950,23 @@ export type QuickReply = {
912
950
  */
913
951
  body: string;
914
952
  };
953
+ /**
954
+ * What a bulk assignment did to one conversation.
955
+ */
956
+ export type ConversationAssignmentResult = {
957
+ /**
958
+ * Conversation ID.
959
+ */
960
+ conversation_id: string;
961
+ /**
962
+ * Member it was to be assigned to.
963
+ */
964
+ assigned_user_id: string;
965
+ /**
966
+ * `assigned`; `not_found` when the organization has no such conversation; `failed` when Ricky could not save it, so retry that conversation.
967
+ */
968
+ status: 'assigned' | 'not_found' | 'failed';
969
+ };
915
970
  /**
916
971
  * A branch or place the agents can send as a WhatsApp location.
917
972
  */
@@ -2271,11 +2326,11 @@ export type WhatsAppNumber = {
2271
2326
  */
2272
2327
  messaging_health: 'available' | 'limited' | 'blocked';
2273
2328
  /**
2274
- * Quality rating at Meta: `GREEN`, `YELLOW`, `RED` or `UNKNOWN`.
2329
+ * Quality rating at Meta: `green`, `yellow`, `red`, `not_yet_determined` or `unknown`.
2275
2330
  */
2276
2331
  quality_rating: string | null;
2277
2332
  /**
2278
- * Messaging limit tier at Meta, for example `TIER_1K` or `TIER_UNLIMITED`.
2333
+ * Messaging limit tier at Meta, for example `TIER_1K` or `TIER_UNLIMITED`; `UNKNOWN` when Meta has not reported it.
2279
2334
  */
2280
2335
  messaging_limit: string | null;
2281
2336
  /**
@@ -2690,6 +2745,33 @@ export type AssignConversationAgent = {
2690
2745
  */
2691
2746
  agent_id: string | null;
2692
2747
  };
2748
+ /**
2749
+ * How the handoff ends.
2750
+ */
2751
+ export type ResolveHandoff = {
2752
+ /**
2753
+ * `returned_to_ai` gives the conversation back to the AI agent that asked for the handoff and unassigns the member; `stayed_with_human` leaves it with the member.
2754
+ */
2755
+ resolution: 'returned_to_ai' | 'stayed_with_human';
2756
+ };
2757
+ /**
2758
+ * Makes members responsible for many conversations at once. Each member also becomes the contact's owner.
2759
+ */
2760
+ export type AssignConversations = {
2761
+ /**
2762
+ * Up to 100 conversations, each once, with the member for each.
2763
+ */
2764
+ assignments: Array<{
2765
+ /**
2766
+ * Conversation to assign.
2767
+ */
2768
+ conversation_id: string;
2769
+ /**
2770
+ * Member who becomes responsible for it.
2771
+ */
2772
+ assigned_user_id: string;
2773
+ }>;
2774
+ };
2693
2775
  /**
2694
2776
  * A contact needs at least a name, a phone or an email.
2695
2777
  */
@@ -2964,12 +3046,20 @@ export type SendMessage = {
2964
3046
  * Message text.
2965
3047
  */
2966
3048
  text: string;
3049
+ /**
3050
+ * Message of this conversation to quote, from `GET /conversations/{conversation_id}/messages`. WhatsApp only.
3051
+ */
3052
+ reply_to_message_id?: string;
2967
3053
  } | {
2968
3054
  type: 'template';
2969
3055
  template: TemplateMessage;
2970
3056
  } | {
2971
3057
  type: 'media';
2972
3058
  media: MediaMessage;
3059
+ /**
3060
+ * Message of this conversation to quote, from `GET /conversations/{conversation_id}/messages`. WhatsApp only.
3061
+ */
3062
+ reply_to_message_id?: string;
2973
3063
  };
2974
3064
  /**
2975
3065
  * Sends a template to a phone number.
@@ -4562,6 +4652,34 @@ export type ListConversationsData = {
4562
4652
  * Only conversations assigned to this member.
4563
4653
  */
4564
4654
  assigned_user_id?: string;
4655
+ /**
4656
+ * Only conversations this AI agent answers and no member is assigned to.
4657
+ */
4658
+ agent_id?: string;
4659
+ /**
4660
+ * `true`: only conversations with no member and no AI agent assigned.
4661
+ */
4662
+ unassigned?: 'true' | 'false';
4663
+ /**
4664
+ * Only conversations on this channel, including earlier connections of the same number or account. See `GET /channels`.
4665
+ */
4666
+ channel_id?: string;
4667
+ /**
4668
+ * Only conversations whose contact has this tag.
4669
+ */
4670
+ tag_id?: string;
4671
+ /**
4672
+ * `true`: only conversations with messages the team has not read.
4673
+ */
4674
+ unread?: 'true' | 'false';
4675
+ /**
4676
+ * `true`: only conversations with a handoff to a person not resolved yet.
4677
+ */
4678
+ pending_handoff?: 'true' | 'false';
4679
+ /**
4680
+ * `customer`: only conversations whose latest message came from the contact.
4681
+ */
4682
+ last_message_from?: 'customer';
4565
4683
  };
4566
4684
  url: '/conversations';
4567
4685
  };
@@ -8098,6 +8216,65 @@ export type ChangeConversationTagsResponses = {
8098
8216
  };
8099
8217
  };
8100
8218
  export type ChangeConversationTagsResponse = ChangeConversationTagsResponses[keyof ChangeConversationTagsResponses];
8219
+ export type MarkConversationUnreadData = {
8220
+ body?: never;
8221
+ headers?: {
8222
+ /**
8223
+ * Optional. A value you choose, unique per logical write, 8–200 characters: a UUID or an ID from your system such as `order-10482-ready`. Retrying with the same key and body replays the first response instead of repeating the write.
8224
+ */
8225
+ 'Idempotency-Key'?: string;
8226
+ };
8227
+ path: {
8228
+ /**
8229
+ * Conversation ID.
8230
+ */
8231
+ conversation_id: string;
8232
+ };
8233
+ query?: never;
8234
+ url: '/conversations/{conversation_id}/read';
8235
+ };
8236
+ export type MarkConversationUnreadErrors = {
8237
+ /**
8238
+ * `invalid_input`: A parameter or body field is invalid; `param` names it when known.
8239
+ */
8240
+ 400: Error;
8241
+ /**
8242
+ * `unauthorized`: The `Authorization` header is missing, malformed, expired or revoked.
8243
+ */
8244
+ 401: Error;
8245
+ /**
8246
+ * `insufficient_scope`: The key lacks the scope this operation requires.
8247
+ */
8248
+ 403: Error;
8249
+ /**
8250
+ * `not_found`: The resource does not exist in this organization.
8251
+ */
8252
+ 404: Error;
8253
+ /**
8254
+ * `idempotency_conflict`: The `Idempotency-Key` was used for a different request.
8255
+ *
8256
+ * `request_processing`: A request with this `Idempotency-Key` is still processing or ended in an unknown state.
8257
+ */
8258
+ 409: Error;
8259
+ /**
8260
+ * `rate_limited`: More than 120 requests this minute with this key; see `Retry-After`.
8261
+ */
8262
+ 429: Error;
8263
+ /**
8264
+ * `internal_error`: Ricky failed. Retry a read. Before retrying a write, read the resource: the same `Idempotency-Key` answers `request_processing`.
8265
+ */
8266
+ 500: Error;
8267
+ };
8268
+ export type MarkConversationUnreadError = MarkConversationUnreadErrors[keyof MarkConversationUnreadErrors];
8269
+ export type MarkConversationUnreadResponses = {
8270
+ /**
8271
+ * Success.
8272
+ */
8273
+ 200: {
8274
+ data: Conversation;
8275
+ };
8276
+ };
8277
+ export type MarkConversationUnreadResponse = MarkConversationUnreadResponses[keyof MarkConversationUnreadResponses];
8101
8278
  export type MarkConversationReadData = {
8102
8279
  body?: never;
8103
8280
  headers?: {
@@ -9230,6 +9407,202 @@ export type ListBroadcastRecipientsResponses = {
9230
9407
  };
9231
9408
  };
9232
9409
  export type ListBroadcastRecipientsResponse = ListBroadcastRecipientsResponses[keyof ListBroadcastRecipientsResponses];
9410
+ export type AssignConversationsData = {
9411
+ body: AssignConversations;
9412
+ headers?: {
9413
+ /**
9414
+ * Optional. A value you choose, unique per logical write, 8–200 characters: a UUID or an ID from your system such as `order-10482-ready`. Retrying with the same key and body replays the first response instead of repeating the write.
9415
+ */
9416
+ 'Idempotency-Key'?: string;
9417
+ };
9418
+ path?: never;
9419
+ query?: never;
9420
+ url: '/conversations/assignments';
9421
+ };
9422
+ export type AssignConversationsErrors = {
9423
+ /**
9424
+ * `invalid_json`: The body is not valid JSON.
9425
+ *
9426
+ * `invalid_input`: A parameter or body field is invalid; `param` names it when known.
9427
+ */
9428
+ 400: Error;
9429
+ /**
9430
+ * `unauthorized`: The `Authorization` header is missing, malformed, expired or revoked.
9431
+ */
9432
+ 401: Error;
9433
+ /**
9434
+ * `insufficient_scope`: The key lacks the scope this operation requires.
9435
+ */
9436
+ 403: Error;
9437
+ /**
9438
+ * `idempotency_conflict`: The `Idempotency-Key` was used for a different request.
9439
+ *
9440
+ * `request_processing`: A request with this `Idempotency-Key` is still processing or ended in an unknown state.
9441
+ */
9442
+ 409: Error;
9443
+ /**
9444
+ * `body_too_large`: The JSON body exceeds 64 KiB.
9445
+ */
9446
+ 413: Error;
9447
+ /**
9448
+ * `unsupported_media_type`: The body must be `application/json`.
9449
+ */
9450
+ 415: Error;
9451
+ /**
9452
+ * `rate_limited`: More than 120 requests this minute with this key; see `Retry-After`.
9453
+ */
9454
+ 429: Error;
9455
+ /**
9456
+ * `internal_error`: Ricky failed. Retry a read. Before retrying a write, read the resource: the same `Idempotency-Key` answers `request_processing`.
9457
+ */
9458
+ 500: Error;
9459
+ };
9460
+ export type AssignConversationsError = AssignConversationsErrors[keyof AssignConversationsErrors];
9461
+ export type AssignConversationsResponses = {
9462
+ /**
9463
+ * Success.
9464
+ */
9465
+ 200: {
9466
+ data: Array<ConversationAssignmentResult>;
9467
+ /**
9468
+ * Pass as `cursor` for the next page; null on the last page.
9469
+ */
9470
+ next_cursor: string | null;
9471
+ };
9472
+ };
9473
+ export type AssignConversationsResponse = AssignConversationsResponses[keyof AssignConversationsResponses];
9474
+ export type ResolveConversationHandoffData = {
9475
+ body: ResolveHandoff;
9476
+ headers?: {
9477
+ /**
9478
+ * Optional. A value you choose, unique per logical write, 8–200 characters: a UUID or an ID from your system such as `order-10482-ready`. Retrying with the same key and body replays the first response instead of repeating the write.
9479
+ */
9480
+ 'Idempotency-Key'?: string;
9481
+ };
9482
+ path: {
9483
+ /**
9484
+ * Conversation ID.
9485
+ */
9486
+ conversation_id: string;
9487
+ };
9488
+ query?: never;
9489
+ url: '/conversations/{conversation_id}/handoff/resolve';
9490
+ };
9491
+ export type ResolveConversationHandoffErrors = {
9492
+ /**
9493
+ * `invalid_json`: The body is not valid JSON.
9494
+ *
9495
+ * `invalid_input`: A parameter or body field is invalid; `param` names it when known.
9496
+ */
9497
+ 400: Error;
9498
+ /**
9499
+ * `unauthorized`: The `Authorization` header is missing, malformed, expired or revoked.
9500
+ */
9501
+ 401: Error;
9502
+ /**
9503
+ * `insufficient_scope`: The key lacks the scope this operation requires.
9504
+ */
9505
+ 403: Error;
9506
+ /**
9507
+ * `not_found`: The resource does not exist in this organization.
9508
+ */
9509
+ 404: Error;
9510
+ /**
9511
+ * `idempotency_conflict`: The `Idempotency-Key` was used for a different request.
9512
+ *
9513
+ * `request_processing`: A request with this `Idempotency-Key` is still processing or ended in an unknown state.
9514
+ */
9515
+ 409: Error;
9516
+ /**
9517
+ * `body_too_large`: The JSON body exceeds 64 KiB.
9518
+ */
9519
+ 413: Error;
9520
+ /**
9521
+ * `unsupported_media_type`: The body must be `application/json`.
9522
+ */
9523
+ 415: Error;
9524
+ /**
9525
+ * `rule_violation`: The request breaks a business rule; `message` says which.
9526
+ */
9527
+ 422: Error;
9528
+ /**
9529
+ * `rate_limited`: More than 120 requests this minute with this key; see `Retry-After`.
9530
+ */
9531
+ 429: Error;
9532
+ /**
9533
+ * `internal_error`: Ricky failed. Retry a read. Before retrying a write, read the resource: the same `Idempotency-Key` answers `request_processing`.
9534
+ */
9535
+ 500: Error;
9536
+ };
9537
+ export type ResolveConversationHandoffError = ResolveConversationHandoffErrors[keyof ResolveConversationHandoffErrors];
9538
+ export type ResolveConversationHandoffResponses = {
9539
+ /**
9540
+ * Success.
9541
+ */
9542
+ 200: {
9543
+ data: Conversation;
9544
+ };
9545
+ };
9546
+ export type ResolveConversationHandoffResponse = ResolveConversationHandoffResponses[keyof ResolveConversationHandoffResponses];
9547
+ export type FetchMessageMediaData = {
9548
+ body?: never;
9549
+ path: {
9550
+ /**
9551
+ * Conversation ID.
9552
+ */
9553
+ conversation_id: string;
9554
+ /**
9555
+ * Message ID.
9556
+ */
9557
+ message_id: string;
9558
+ };
9559
+ query?: never;
9560
+ url: '/conversations/{conversation_id}/messages/{message_id}/media';
9561
+ };
9562
+ export type FetchMessageMediaErrors = {
9563
+ /**
9564
+ * `invalid_input`: A parameter or body field is invalid; `param` names it when known.
9565
+ */
9566
+ 400: Error;
9567
+ /**
9568
+ * `unauthorized`: The `Authorization` header is missing, malformed, expired or revoked.
9569
+ */
9570
+ 401: Error;
9571
+ /**
9572
+ * `insufficient_scope`: The key lacks the scope this operation requires.
9573
+ */
9574
+ 403: Error;
9575
+ /**
9576
+ * `not_found`: The resource does not exist in this organization.
9577
+ */
9578
+ 404: Error;
9579
+ /**
9580
+ * `rule_violation`: The request breaks a business rule; `message` says which.
9581
+ */
9582
+ 422: Error;
9583
+ /**
9584
+ * `rate_limited`: More than 120 requests this minute with this key; see `Retry-After`.
9585
+ */
9586
+ 429: Error;
9587
+ /**
9588
+ * `internal_error`: Ricky failed. Retry a read. Before retrying a write, read the resource: the same `Idempotency-Key` answers `request_processing`.
9589
+ */
9590
+ 500: Error;
9591
+ /**
9592
+ * `upstream_error`: The messaging provider failed. Retry later.
9593
+ */
9594
+ 502: Error;
9595
+ };
9596
+ export type FetchMessageMediaError = FetchMessageMediaErrors[keyof FetchMessageMediaErrors];
9597
+ export type FetchMessageMediaResponses = {
9598
+ /**
9599
+ * Success.
9600
+ */
9601
+ 200: {
9602
+ data: Message;
9603
+ };
9604
+ };
9605
+ export type FetchMessageMediaResponse = FetchMessageMediaResponses[keyof FetchMessageMediaResponses];
9233
9606
  export type WebhookMessageReceivedWebhookPayload = WebhookEvent;
9234
9607
  export type WebhookMessageReceivedWebhookRequest = {
9235
9608
  body: WebhookMessageReceivedWebhookPayload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "getricky",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Official TypeScript SDK for the Ricky REST API",
5
5
  "keywords": [
6
6
  "api",