getricky 0.1.41 → 0.1.42

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.
@@ -3296,6 +3296,134 @@ export type BusinessHours = {
3296
3296
  */
3297
3297
  weekdays: Array<number>;
3298
3298
  };
3299
+ /**
3300
+ * A yes-or-no question: a comparison of one field, or a group. Each trigger offers its own fields; a `decision` also reads `variable`.
3301
+ */
3302
+ export type Condition = {
3303
+ kind: 'compare';
3304
+ field: 'assignee';
3305
+ /**
3306
+ * `is` holds for any of `values`; `is_not` for none.
3307
+ */
3308
+ operator: 'is' | 'is_not';
3309
+ /**
3310
+ * Who has the conversation: a member, an agent or nobody.
3311
+ */
3312
+ values: Array<{
3313
+ kind: 'person';
3314
+ /**
3315
+ * A member. See `GET /members`.
3316
+ */
3317
+ user_id: string;
3318
+ } | {
3319
+ kind: 'agent';
3320
+ /**
3321
+ * An AI agent.
3322
+ */
3323
+ agent_id: string;
3324
+ } | {
3325
+ kind: 'nobody';
3326
+ }>;
3327
+ } | {
3328
+ kind: 'compare';
3329
+ field: 'conversation_status';
3330
+ /**
3331
+ * `is` holds for any of `values`; `is_not` for none.
3332
+ */
3333
+ operator: 'is' | 'is_not';
3334
+ /**
3335
+ * Open or closed.
3336
+ */
3337
+ values: Array<'open' | 'closed'>;
3338
+ } | {
3339
+ kind: 'compare';
3340
+ field: 'ai';
3341
+ /**
3342
+ * `is` holds for any of `values`; `is_not` for none.
3343
+ */
3344
+ operator: 'is' | 'is_not';
3345
+ /**
3346
+ * `on` while an AI agent answers the conversation, as its assignee or with the AI on in it.
3347
+ */
3348
+ values: Array<'on' | 'off'>;
3349
+ } | {
3350
+ kind: 'compare';
3351
+ field: 'channel';
3352
+ /**
3353
+ * `is` holds for any of `values`; `is_not` for none.
3354
+ */
3355
+ operator: 'is' | 'is_not';
3356
+ /**
3357
+ * Channels. See `GET /channels`.
3358
+ */
3359
+ values: Array<string>;
3360
+ } | {
3361
+ kind: 'compare';
3362
+ field: 'time';
3363
+ /**
3364
+ * Whether the moment of evaluation is within the hours or outside them.
3365
+ */
3366
+ operator: 'within' | 'outside';
3367
+ business_hours: BusinessHours;
3368
+ } | {
3369
+ kind: 'compare';
3370
+ field: 'message_first';
3371
+ /**
3372
+ * `is` when the contact wrote first in the conversation, before any message from the business.
3373
+ */
3374
+ operator: 'is' | 'is_not';
3375
+ } | {
3376
+ kind: 'compare';
3377
+ field: 'message_type';
3378
+ /**
3379
+ * `is` holds for any of `values`; `is_not` for none.
3380
+ */
3381
+ operator: 'is' | 'is_not';
3382
+ /**
3383
+ * The kind of message; `button` is a tapped button or list option on any channel.
3384
+ */
3385
+ values: Array<'text' | 'button' | 'image' | 'audio' | 'video' | 'document' | 'location' | 'sticker' | 'other'>;
3386
+ } | {
3387
+ kind: 'compare';
3388
+ field: 'message_text';
3389
+ operator: 'contains' | 'not_contains';
3390
+ /**
3391
+ * Compared ignoring case, accents and repeated spaces.
3392
+ */
3393
+ value: string;
3394
+ } | {
3395
+ kind: 'compare';
3396
+ field: 'message_sender';
3397
+ /**
3398
+ * `is` holds for any of `values`; `is_not` for none.
3399
+ */
3400
+ operator: 'is' | 'is_not';
3401
+ /**
3402
+ * Who sent the message: `person` (the team), `ai` (an AI agent and its tools), `automation` (a workflow), `broadcast` or `external_app` (another app connected to the channel).
3403
+ */
3404
+ values: Array<'person' | 'ai' | 'automation' | 'broadcast' | 'external_app'>;
3405
+ } | {
3406
+ kind: 'compare';
3407
+ field: 'variable';
3408
+ /**
3409
+ * The `answer_key` an earlier `ask_question` step saved.
3410
+ */
3411
+ name: string;
3412
+ operator: 'is' | 'is_not' | 'contains' | 'not_contains' | 'exists' | 'not_exists';
3413
+ /**
3414
+ * Compared ignoring case and accents; absent for `exists` and `not_exists`.
3415
+ */
3416
+ value?: string;
3417
+ } | {
3418
+ /**
3419
+ * `all` holds when every condition holds; `any` when at least one does.
3420
+ */
3421
+ kind: 'all' | 'any';
3422
+ /**
3423
+ * Comparisons or groups, three levels deep at most.
3424
+ */
3425
+ conditions: Array<Condition>;
3426
+ };
3299
3427
  /**
3300
3428
  * An automation Ricky runs for the organization.
3301
3429
  */
@@ -3318,87 +3446,39 @@ export type Workflow = {
3318
3446
  type: 'conversation' | 'scheduled';
3319
3447
  definition: {
3320
3448
  /**
3321
- * `conversation_opened` runs when a conversation opens; `first_message_received` when the contact writes first in a conversation, before any message from the business; `message_received` on every incoming message; `message_sent` within 15 minutes of an outgoing message that passes `sent_message_filters`, unless the contact replied first. `at_time` runs once a day at `at_time.time`, on its weekdays, on each conversation of its channels assigned then to one of `conversation_filters.assigned_user_ids` (open ones only with `conversation_filters.only_open`); it has no `condition`. `conversation_assigned` runs when a conversation of its channels is assigned to a member (any member, or one of `conversation_filters.assigned_user_ids`) while its `condition` holds; the assignment an AI handoff makes does not run it. Both take only `turn_on_ai` and `turn_off_ai` steps, which only they take. `call_received` decides who answers a WhatsApp call on its channels (WhatsApp numbers with AI calls on): its flow takes only `answer_call`, `decline_call` and a `branch` on `business_hours`, and the first active one that reaches a call step decides, over whoever holds the conversation.
3449
+ * The event that starts the workflow; `condition` decides whether that occurrence runs it. `conversation_opened` runs when a conversation opens; `first_message_received` when the contact writes first in a conversation, before any message from the business; `message_received` on every incoming message; `message_sent` within 15 minutes of an outgoing message, unless the contact replied first; `conversation_inactive` and `team_message_unanswered` after `inactivity_seconds`. `schedule` runs at each of its `schedule.times` on each conversation assigned then to a member its `condition` names with `assignee` `is`, which it requires. `conversation_assigned` runs when a conversation is assigned to a member; the assignment an AI handoff makes does not run it. Both take only `turn_on_ai`, `turn_off_ai`, `decision` and `end` steps, and only they take `turn_on_ai` and `turn_off_ai`. `call_received` decides who answers a WhatsApp call on the WhatsApp numbers with AI calls on that its `condition` names: its flow takes only `answer_call`, `decline_call` and `decision`s on `channel` and `time`, and the first active one that reaches a call step decides, over whoever holds the conversation.
3322
3450
  */
3323
- trigger: 'at_time' | 'conversation_assigned' | 'conversation_inactive' | 'conversation_opened' | 'first_message_received' | 'message_received' | 'message_sent' | 'team_message_unanswered' | 'call_received';
3451
+ trigger: 'conversation_opened' | 'first_message_received' | 'message_received' | 'message_sent' | 'conversation_inactive' | 'team_message_unanswered' | 'schedule' | 'conversation_assigned' | 'call_received';
3324
3452
  /**
3325
- * Channels it listens to. See `GET /channels`.
3453
+ * Whether an occurrence of the trigger runs the workflow; null runs every occurrence on every channel.
3326
3454
  */
3327
- channel_ids: Array<string>;
3328
- /**
3329
- * Seconds without activity before starting the flow: since the last team reply for team_message_unanswered, or the last message or reaction from either side for conversation_inactive.
3330
- */
3331
- inactivity_seconds?: number;
3455
+ condition: Condition | null;
3332
3456
  /**
3333
- * Which messages a `message_received` workflow reacts to.
3457
+ * When a `schedule` workflow runs; required for it and only for it.
3334
3458
  */
3335
- message_filters?: {
3459
+ schedule?: {
3336
3460
  /**
3337
- * Match the contact writing first, before any message from the business, OR only_unassigned. Neither selected matches every message.
3338
- */
3339
- first_message?: boolean;
3340
- /**
3341
- * Match while nobody has the conversation; OR first_message when selected.
3342
- */
3343
- only_unassigned: boolean;
3344
- /**
3345
- * Not when the customer taps a button.
3346
- */
3347
- skip_buttons: boolean;
3348
- };
3349
- /**
3350
- * Which outgoing messages a `message_sent` workflow reacts to; required for it.
3351
- */
3352
- sent_message_filters?: {
3353
- /**
3354
- * Who sent it: `person` (the team), `ai` (an AI agent, including its tools), `automation` (a workflow), `broadcast`, or `external_app` (another app connected to the channel). Each at most once.
3355
- */
3356
- senders: Array<'person' | 'ai' | 'automation' | 'broadcast' | 'external_app'>;
3357
- /**
3358
- * Only when the message contains this text, ignoring case, accents and repeated spaces.
3359
- */
3360
- text_contains?: string;
3361
- };
3362
- /**
3363
- * When an `at_time` workflow runs; required for it and only for it.
3364
- */
3365
- at_time?: {
3366
- /**
3367
- * Quarter hour it runs, `HH:MM`.
3368
- */
3369
- time: string;
3370
- /**
3371
- * IANA time zone of `time` and `weekdays`.
3461
+ * IANA time zone of every time.
3372
3462
  */
3373
3463
  timezone: string;
3374
3464
  /**
3375
- * Days it runs, 0 for Sunday to 6 for Saturday. Each at most once.
3376
- */
3377
- weekdays: Array<number>;
3378
- };
3379
- /**
3380
- * Which conversations `at_time` and `conversation_assigned` reach; only for them.
3381
- */
3382
- conversation_filters?: {
3383
- /**
3384
- * Members the conversation is assigned to. Required for `at_time`; omitted on `conversation_assigned`, any member. See `GET /members`.
3465
+ * Each time and its days; each time of each day at most once.
3385
3466
  */
3386
- assigned_user_ids?: Array<string>;
3387
- /**
3388
- * Only open conversations.
3389
- */
3390
- only_open: boolean;
3467
+ times: Array<{
3468
+ /**
3469
+ * Quarter hour it runs, `HH:MM`.
3470
+ */
3471
+ time: string;
3472
+ /**
3473
+ * Days it runs at that time, 0 for Sunday to 6 for Saturday.
3474
+ */
3475
+ weekdays: Array<number>;
3476
+ }>;
3391
3477
  };
3392
3478
  /**
3393
- * When it runs; null runs at any hour.
3479
+ * Seconds without activity before starting the flow: since the last team reply for team_message_unanswered, or the last message or reaction from either side for conversation_inactive.
3394
3480
  */
3395
- condition: {
3396
- kind: 'inside_business_hours';
3397
- business_hours: BusinessHours;
3398
- } | {
3399
- kind: 'outside_business_hours';
3400
- business_hours: BusinessHours;
3401
- } | null;
3481
+ inactivity_seconds?: number;
3402
3482
  /**
3403
3483
  * The steps and how they connect.
3404
3484
  */
@@ -3439,7 +3519,7 @@ export type Workflow = {
3439
3519
  */
3440
3520
  text: string;
3441
3521
  /**
3442
- * Name the answer is kept under, for a later `branch`.
3522
+ * Name the answer is kept under, for a later `decision` to compare as a `variable`.
3443
3523
  */
3444
3524
  answer_key: string;
3445
3525
  /**
@@ -3476,31 +3556,29 @@ export type Workflow = {
3476
3556
  * Step ID: letters, digits, `_` or `-`, up to 64.
3477
3557
  */
3478
3558
  id: string;
3559
+ kind: 'decision';
3479
3560
  /**
3480
- * Step to run next; null ends the flow.
3481
- */
3482
- next: string | null;
3483
- kind: 'branch';
3484
- /**
3485
- * Name the answer is kept under, for a later `branch`.
3486
- */
3487
- answer_key?: string;
3488
- /**
3489
- * How the answer is compared. With `answer_key` and `value`.
3490
- */
3491
- operator?: 'equals' | 'contains' | 'exists';
3492
- /**
3493
- * Value compared with the answer.
3561
+ * Branches in the order they are checked; the first that holds is taken.
3494
3562
  */
3495
- value?: string;
3496
- /**
3497
- * Holds while the business is open at the moment the step runs. Send it instead of `answer_key`, `operator` and `value`.
3498
- */
3499
- business_hours?: BusinessHours;
3563
+ branches: Array<{
3564
+ /**
3565
+ * Step ID: letters, digits, `_` or `-`, up to 64.
3566
+ */
3567
+ id: string;
3568
+ /**
3569
+ * Branch name, unique in the decision.
3570
+ */
3571
+ name: string;
3572
+ condition: Condition;
3573
+ /**
3574
+ * Step to run when this branch is the first whose condition holds.
3575
+ */
3576
+ next: string | null;
3577
+ }>;
3500
3578
  /**
3501
- * Step to run when the condition does not hold; `next` when it does.
3579
+ * Step to run when no branch holds («Si no»); null ends the flow.
3502
3580
  */
3503
- otherwise: string | null;
3581
+ next: string | null;
3504
3582
  } | {
3505
3583
  /**
3506
3584
  * Step ID: letters, digits, `_` or `-`, up to 64.
@@ -5007,6 +5085,134 @@ export type BusinessHoursInput = {
5007
5085
  */
5008
5086
  weekdays?: Array<number>;
5009
5087
  };
5088
+ /**
5089
+ * A yes-or-no question: a comparison of one field, or a group. Each trigger offers its own fields; a `decision` also reads `variable`.
5090
+ */
5091
+ export type ConditionInput = {
5092
+ kind: 'compare';
5093
+ field: 'assignee';
5094
+ /**
5095
+ * `is` holds for any of `values`; `is_not` for none.
5096
+ */
5097
+ operator: 'is' | 'is_not';
5098
+ /**
5099
+ * Who has the conversation: a member, an agent or nobody.
5100
+ */
5101
+ values: Array<{
5102
+ kind: 'person';
5103
+ /**
5104
+ * A member. See `GET /members`.
5105
+ */
5106
+ user_id: string;
5107
+ } | {
5108
+ kind: 'agent';
5109
+ /**
5110
+ * An AI agent.
5111
+ */
5112
+ agent_id: string;
5113
+ } | {
5114
+ kind: 'nobody';
5115
+ }>;
5116
+ } | {
5117
+ kind: 'compare';
5118
+ field: 'conversation_status';
5119
+ /**
5120
+ * `is` holds for any of `values`; `is_not` for none.
5121
+ */
5122
+ operator: 'is' | 'is_not';
5123
+ /**
5124
+ * Open or closed.
5125
+ */
5126
+ values: Array<'open' | 'closed'>;
5127
+ } | {
5128
+ kind: 'compare';
5129
+ field: 'ai';
5130
+ /**
5131
+ * `is` holds for any of `values`; `is_not` for none.
5132
+ */
5133
+ operator: 'is' | 'is_not';
5134
+ /**
5135
+ * `on` while an AI agent answers the conversation, as its assignee or with the AI on in it.
5136
+ */
5137
+ values: Array<'on' | 'off'>;
5138
+ } | {
5139
+ kind: 'compare';
5140
+ field: 'channel';
5141
+ /**
5142
+ * `is` holds for any of `values`; `is_not` for none.
5143
+ */
5144
+ operator: 'is' | 'is_not';
5145
+ /**
5146
+ * Channels. See `GET /channels`.
5147
+ */
5148
+ values: Array<string>;
5149
+ } | {
5150
+ kind: 'compare';
5151
+ field: 'time';
5152
+ /**
5153
+ * Whether the moment of evaluation is within the hours or outside them.
5154
+ */
5155
+ operator: 'within' | 'outside';
5156
+ business_hours: BusinessHoursInput;
5157
+ } | {
5158
+ kind: 'compare';
5159
+ field: 'message_first';
5160
+ /**
5161
+ * `is` when the contact wrote first in the conversation, before any message from the business.
5162
+ */
5163
+ operator: 'is' | 'is_not';
5164
+ } | {
5165
+ kind: 'compare';
5166
+ field: 'message_type';
5167
+ /**
5168
+ * `is` holds for any of `values`; `is_not` for none.
5169
+ */
5170
+ operator: 'is' | 'is_not';
5171
+ /**
5172
+ * The kind of message; `button` is a tapped button or list option on any channel.
5173
+ */
5174
+ values: Array<'text' | 'button' | 'image' | 'audio' | 'video' | 'document' | 'location' | 'sticker' | 'other'>;
5175
+ } | {
5176
+ kind: 'compare';
5177
+ field: 'message_text';
5178
+ operator: 'contains' | 'not_contains';
5179
+ /**
5180
+ * Compared ignoring case, accents and repeated spaces.
5181
+ */
5182
+ value: string;
5183
+ } | {
5184
+ kind: 'compare';
5185
+ field: 'message_sender';
5186
+ /**
5187
+ * `is` holds for any of `values`; `is_not` for none.
5188
+ */
5189
+ operator: 'is' | 'is_not';
5190
+ /**
5191
+ * Who sent the message: `person` (the team), `ai` (an AI agent and its tools), `automation` (a workflow), `broadcast` or `external_app` (another app connected to the channel).
5192
+ */
5193
+ values: Array<'person' | 'ai' | 'automation' | 'broadcast' | 'external_app'>;
5194
+ } | {
5195
+ kind: 'compare';
5196
+ field: 'variable';
5197
+ /**
5198
+ * The `answer_key` an earlier `ask_question` step saved.
5199
+ */
5200
+ name: string;
5201
+ operator: 'is' | 'is_not' | 'contains' | 'not_contains' | 'exists' | 'not_exists';
5202
+ /**
5203
+ * Compared ignoring case and accents; absent for `exists` and `not_exists`.
5204
+ */
5205
+ value?: string;
5206
+ } | {
5207
+ /**
5208
+ * `all` holds when every condition holds; `any` when at least one does.
5209
+ */
5210
+ kind: 'all' | 'any';
5211
+ /**
5212
+ * Comparisons or groups, three levels deep at most.
5213
+ */
5214
+ conditions: Array<ConditionInput>;
5215
+ };
5010
5216
  /**
5011
5217
  * Creates a conversation workflow as a `draft`. Activating it is a separate call.
5012
5218
  */
@@ -5016,23 +5222,55 @@ export type CreateWorkflow = {
5016
5222
  */
5017
5223
  name: string;
5018
5224
  /**
5019
- * Reacts to a conversation with messages, questions, waits and assignments.
5225
+ * Reacts to a conversation with messages, questions, decisions, waits and assignments.
5020
5226
  */
5021
5227
  definition: {
5022
5228
  /**
5023
- * `conversation_opened` runs when a conversation opens; `first_message_received` when the contact writes first in a conversation, before any message from the business; `message_received` on every incoming message; `message_sent` within 15 minutes of an outgoing message that passes `sent_message_filters`, unless the contact replied first. `at_time` runs once a day at `at_time.time`, on its weekdays, on each conversation of its channels assigned then to one of `conversation_filters.assigned_user_ids` (open ones only with `conversation_filters.only_open`); it has no `condition`. `conversation_assigned` runs when a conversation of its channels is assigned to a member (any member, or one of `conversation_filters.assigned_user_ids`) while its `condition` holds; the assignment an AI handoff makes does not run it. Both take only `turn_on_ai` and `turn_off_ai` steps, which only they take. `call_received` decides who answers a WhatsApp call on its channels (WhatsApp numbers with AI calls on): its flow takes only `answer_call`, `decline_call` and a `branch` on `business_hours`, and the first active one that reaches a call step decides, over whoever holds the conversation.
5229
+ * The event that starts the workflow; `condition` decides whether that occurrence runs it. `conversation_opened` runs when a conversation opens; `first_message_received` when the contact writes first in a conversation, before any message from the business; `message_received` on every incoming message; `message_sent` within 15 minutes of an outgoing message, unless the contact replied first; `conversation_inactive` and `team_message_unanswered` after `inactivity_seconds`. `schedule` runs at each of its `schedule.times` on each conversation assigned then to a member its `condition` names with `assignee` `is`, which it requires. `conversation_assigned` runs when a conversation is assigned to a member; the assignment an AI handoff makes does not run it. Both take only `turn_on_ai`, `turn_off_ai`, `decision` and `end` steps, and only they take `turn_on_ai` and `turn_off_ai`. `call_received` decides who answers a WhatsApp call on the WhatsApp numbers with AI calls on that its `condition` names: its flow takes only `answer_call`, `decline_call` and `decision`s on `channel` and `time`, and the first active one that reaches a call step decides, over whoever holds the conversation. `at_time` is deprecated: read as `schedule`.
5024
5230
  */
5025
- trigger: 'at_time' | 'conversation_assigned' | 'conversation_inactive' | 'conversation_opened' | 'first_message_received' | 'message_received' | 'message_sent' | 'team_message_unanswered' | 'call_received';
5231
+ trigger: 'conversation_opened' | 'first_message_received' | 'message_received' | 'message_sent' | 'conversation_inactive' | 'team_message_unanswered' | 'schedule' | 'conversation_assigned' | 'call_received' | 'at_time';
5026
5232
  /**
5027
- * Channels it listens to. See `GET /channels`.
5233
+ * Whether an occurrence of the trigger runs the workflow; null runs every occurrence on every channel.
5028
5234
  */
5029
- channel_ids: Array<string>;
5235
+ condition: ConditionInput | {
5236
+ kind: 'inside_business_hours';
5237
+ business_hours: BusinessHoursInput;
5238
+ } | {
5239
+ kind: 'outside_business_hours';
5240
+ business_hours: BusinessHoursInput;
5241
+ } | null;
5242
+ /**
5243
+ * When a `schedule` workflow runs; required for it and only for it.
5244
+ */
5245
+ schedule?: {
5246
+ /**
5247
+ * IANA time zone of every time.
5248
+ */
5249
+ timezone: string;
5250
+ /**
5251
+ * Each time and its days; each time of each day at most once.
5252
+ */
5253
+ times: Array<{
5254
+ /**
5255
+ * Quarter hour it runs, `HH:MM`.
5256
+ */
5257
+ time: string;
5258
+ /**
5259
+ * Days it runs at that time, 0 for Sunday to 6 for Saturday.
5260
+ */
5261
+ weekdays: Array<number>;
5262
+ }>;
5263
+ };
5030
5264
  /**
5031
5265
  * Seconds without activity before starting the flow: since the last team reply for team_message_unanswered, or the last message or reaction from either side for conversation_inactive.
5032
5266
  */
5033
5267
  inactivity_seconds?: number;
5034
5268
  /**
5035
- * Which messages a `message_received` workflow reacts to.
5269
+ * Deprecated: read as a `channel` comparison in `condition`.
5270
+ */
5271
+ channel_ids?: Array<string>;
5272
+ /**
5273
+ * Deprecated, requests only: read as `condition` comparisons on `message_first`, `assignee` (nobody) and `message_type` (not `button`).
5036
5274
  */
5037
5275
  message_filters?: {
5038
5276
  /**
@@ -5049,7 +5287,7 @@ export type CreateWorkflow = {
5049
5287
  skip_buttons: boolean;
5050
5288
  };
5051
5289
  /**
5052
- * Which outgoing messages a `message_sent` workflow reacts to; required for it.
5290
+ * Deprecated, requests only: read as `condition` comparisons on `message_sender` and `message_text`.
5053
5291
  */
5054
5292
  sent_message_filters?: {
5055
5293
  /**
@@ -5062,7 +5300,7 @@ export type CreateWorkflow = {
5062
5300
  text_contains?: string;
5063
5301
  };
5064
5302
  /**
5065
- * When an `at_time` workflow runs; required for it and only for it.
5303
+ * Deprecated, requests only: an `at_time` workflow is read as `schedule` with this one time.
5066
5304
  */
5067
5305
  at_time?: {
5068
5306
  /**
@@ -5079,7 +5317,7 @@ export type CreateWorkflow = {
5079
5317
  weekdays: Array<number>;
5080
5318
  };
5081
5319
  /**
5082
- * Which conversations `at_time` and `conversation_assigned` reach; only for them.
5320
+ * Deprecated, requests only: read as `condition` comparisons on `assignee` and `conversation_status`.
5083
5321
  */
5084
5322
  conversation_filters?: {
5085
5323
  /**
@@ -5091,16 +5329,6 @@ export type CreateWorkflow = {
5091
5329
  */
5092
5330
  only_open: boolean;
5093
5331
  };
5094
- /**
5095
- * When it runs; null runs at any hour.
5096
- */
5097
- condition: {
5098
- kind: 'inside_business_hours';
5099
- business_hours: BusinessHoursInput;
5100
- } | {
5101
- kind: 'outside_business_hours';
5102
- business_hours: BusinessHoursInput;
5103
- } | null;
5104
5332
  /**
5105
5333
  * The steps and how they connect.
5106
5334
  */
@@ -5141,7 +5369,7 @@ export type CreateWorkflow = {
5141
5369
  */
5142
5370
  text: string;
5143
5371
  /**
5144
- * Name the answer is kept under, for a later `branch`.
5372
+ * Name the answer is kept under, for a later `decision` to compare as a `variable`.
5145
5373
  */
5146
5374
  answer_key: string;
5147
5375
  /**
@@ -5173,6 +5401,34 @@ export type CreateWorkflow = {
5173
5401
  * Step to run when the answer matches no option.
5174
5402
  */
5175
5403
  on_invalid: string | null;
5404
+ } | {
5405
+ /**
5406
+ * Step ID: letters, digits, `_` or `-`, up to 64.
5407
+ */
5408
+ id: string;
5409
+ kind: 'decision';
5410
+ /**
5411
+ * Branches in the order they are checked; the first that holds is taken.
5412
+ */
5413
+ branches: Array<{
5414
+ /**
5415
+ * Step ID: letters, digits, `_` or `-`, up to 64.
5416
+ */
5417
+ id: string;
5418
+ /**
5419
+ * Branch name, unique in the decision.
5420
+ */
5421
+ name: string;
5422
+ condition: ConditionInput;
5423
+ /**
5424
+ * Step to run when this branch is the first whose condition holds.
5425
+ */
5426
+ next: string | null;
5427
+ }>;
5428
+ /**
5429
+ * Step to run when no branch holds («Si no»); null ends the flow.
5430
+ */
5431
+ next: string | null;
5176
5432
  } | {
5177
5433
  /**
5178
5434
  * Step ID: letters, digits, `_` or `-`, up to 64.
@@ -5184,7 +5440,7 @@ export type CreateWorkflow = {
5184
5440
  next: string | null;
5185
5441
  kind: 'branch';
5186
5442
  /**
5187
- * Name the answer is kept under, for a later `branch`.
5443
+ * Name the answer is kept under, for a later `decision` to compare as a `variable`.
5188
5444
  */
5189
5445
  answer_key?: string;
5190
5446
  /**
@@ -5338,19 +5594,51 @@ export type UpdateWorkflow = {
5338
5594
  */
5339
5595
  definition?: {
5340
5596
  /**
5341
- * `conversation_opened` runs when a conversation opens; `first_message_received` when the contact writes first in a conversation, before any message from the business; `message_received` on every incoming message; `message_sent` within 15 minutes of an outgoing message that passes `sent_message_filters`, unless the contact replied first. `at_time` runs once a day at `at_time.time`, on its weekdays, on each conversation of its channels assigned then to one of `conversation_filters.assigned_user_ids` (open ones only with `conversation_filters.only_open`); it has no `condition`. `conversation_assigned` runs when a conversation of its channels is assigned to a member (any member, or one of `conversation_filters.assigned_user_ids`) while its `condition` holds; the assignment an AI handoff makes does not run it. Both take only `turn_on_ai` and `turn_off_ai` steps, which only they take. `call_received` decides who answers a WhatsApp call on its channels (WhatsApp numbers with AI calls on): its flow takes only `answer_call`, `decline_call` and a `branch` on `business_hours`, and the first active one that reaches a call step decides, over whoever holds the conversation.
5597
+ * The event that starts the workflow; `condition` decides whether that occurrence runs it. `conversation_opened` runs when a conversation opens; `first_message_received` when the contact writes first in a conversation, before any message from the business; `message_received` on every incoming message; `message_sent` within 15 minutes of an outgoing message, unless the contact replied first; `conversation_inactive` and `team_message_unanswered` after `inactivity_seconds`. `schedule` runs at each of its `schedule.times` on each conversation assigned then to a member its `condition` names with `assignee` `is`, which it requires. `conversation_assigned` runs when a conversation is assigned to a member; the assignment an AI handoff makes does not run it. Both take only `turn_on_ai`, `turn_off_ai`, `decision` and `end` steps, and only they take `turn_on_ai` and `turn_off_ai`. `call_received` decides who answers a WhatsApp call on the WhatsApp numbers with AI calls on that its `condition` names: its flow takes only `answer_call`, `decline_call` and `decision`s on `channel` and `time`, and the first active one that reaches a call step decides, over whoever holds the conversation. `at_time` is deprecated: read as `schedule`.
5342
5598
  */
5343
- trigger: 'at_time' | 'conversation_assigned' | 'conversation_inactive' | 'conversation_opened' | 'first_message_received' | 'message_received' | 'message_sent' | 'team_message_unanswered' | 'call_received';
5599
+ trigger: 'conversation_opened' | 'first_message_received' | 'message_received' | 'message_sent' | 'conversation_inactive' | 'team_message_unanswered' | 'schedule' | 'conversation_assigned' | 'call_received' | 'at_time';
5344
5600
  /**
5345
- * Channels it listens to. See `GET /channels`.
5601
+ * Whether an occurrence of the trigger runs the workflow; null runs every occurrence on every channel.
5346
5602
  */
5347
- channel_ids: Array<string>;
5603
+ condition: ConditionInput | {
5604
+ kind: 'inside_business_hours';
5605
+ business_hours: BusinessHoursInput;
5606
+ } | {
5607
+ kind: 'outside_business_hours';
5608
+ business_hours: BusinessHoursInput;
5609
+ } | null;
5610
+ /**
5611
+ * When a `schedule` workflow runs; required for it and only for it.
5612
+ */
5613
+ schedule?: {
5614
+ /**
5615
+ * IANA time zone of every time.
5616
+ */
5617
+ timezone: string;
5618
+ /**
5619
+ * Each time and its days; each time of each day at most once.
5620
+ */
5621
+ times: Array<{
5622
+ /**
5623
+ * Quarter hour it runs, `HH:MM`.
5624
+ */
5625
+ time: string;
5626
+ /**
5627
+ * Days it runs at that time, 0 for Sunday to 6 for Saturday.
5628
+ */
5629
+ weekdays: Array<number>;
5630
+ }>;
5631
+ };
5348
5632
  /**
5349
5633
  * Seconds without activity before starting the flow: since the last team reply for team_message_unanswered, or the last message or reaction from either side for conversation_inactive.
5350
5634
  */
5351
5635
  inactivity_seconds?: number;
5352
5636
  /**
5353
- * Which messages a `message_received` workflow reacts to.
5637
+ * Deprecated: read as a `channel` comparison in `condition`.
5638
+ */
5639
+ channel_ids?: Array<string>;
5640
+ /**
5641
+ * Deprecated, requests only: read as `condition` comparisons on `message_first`, `assignee` (nobody) and `message_type` (not `button`).
5354
5642
  */
5355
5643
  message_filters?: {
5356
5644
  /**
@@ -5367,7 +5655,7 @@ export type UpdateWorkflow = {
5367
5655
  skip_buttons: boolean;
5368
5656
  };
5369
5657
  /**
5370
- * Which outgoing messages a `message_sent` workflow reacts to; required for it.
5658
+ * Deprecated, requests only: read as `condition` comparisons on `message_sender` and `message_text`.
5371
5659
  */
5372
5660
  sent_message_filters?: {
5373
5661
  /**
@@ -5380,7 +5668,7 @@ export type UpdateWorkflow = {
5380
5668
  text_contains?: string;
5381
5669
  };
5382
5670
  /**
5383
- * When an `at_time` workflow runs; required for it and only for it.
5671
+ * Deprecated, requests only: an `at_time` workflow is read as `schedule` with this one time.
5384
5672
  */
5385
5673
  at_time?: {
5386
5674
  /**
@@ -5397,7 +5685,7 @@ export type UpdateWorkflow = {
5397
5685
  weekdays: Array<number>;
5398
5686
  };
5399
5687
  /**
5400
- * Which conversations `at_time` and `conversation_assigned` reach; only for them.
5688
+ * Deprecated, requests only: read as `condition` comparisons on `assignee` and `conversation_status`.
5401
5689
  */
5402
5690
  conversation_filters?: {
5403
5691
  /**
@@ -5409,16 +5697,6 @@ export type UpdateWorkflow = {
5409
5697
  */
5410
5698
  only_open: boolean;
5411
5699
  };
5412
- /**
5413
- * When it runs; null runs at any hour.
5414
- */
5415
- condition: {
5416
- kind: 'inside_business_hours';
5417
- business_hours: BusinessHoursInput;
5418
- } | {
5419
- kind: 'outside_business_hours';
5420
- business_hours: BusinessHoursInput;
5421
- } | null;
5422
5700
  /**
5423
5701
  * The steps and how they connect.
5424
5702
  */
@@ -5459,7 +5737,7 @@ export type UpdateWorkflow = {
5459
5737
  */
5460
5738
  text: string;
5461
5739
  /**
5462
- * Name the answer is kept under, for a later `branch`.
5740
+ * Name the answer is kept under, for a later `decision` to compare as a `variable`.
5463
5741
  */
5464
5742
  answer_key: string;
5465
5743
  /**
@@ -5491,6 +5769,34 @@ export type UpdateWorkflow = {
5491
5769
  * Step to run when the answer matches no option.
5492
5770
  */
5493
5771
  on_invalid: string | null;
5772
+ } | {
5773
+ /**
5774
+ * Step ID: letters, digits, `_` or `-`, up to 64.
5775
+ */
5776
+ id: string;
5777
+ kind: 'decision';
5778
+ /**
5779
+ * Branches in the order they are checked; the first that holds is taken.
5780
+ */
5781
+ branches: Array<{
5782
+ /**
5783
+ * Step ID: letters, digits, `_` or `-`, up to 64.
5784
+ */
5785
+ id: string;
5786
+ /**
5787
+ * Branch name, unique in the decision.
5788
+ */
5789
+ name: string;
5790
+ condition: ConditionInput;
5791
+ /**
5792
+ * Step to run when this branch is the first whose condition holds.
5793
+ */
5794
+ next: string | null;
5795
+ }>;
5796
+ /**
5797
+ * Step to run when no branch holds («Si no»); null ends the flow.
5798
+ */
5799
+ next: string | null;
5494
5800
  } | {
5495
5801
  /**
5496
5802
  * Step ID: letters, digits, `_` or `-`, up to 64.
@@ -5502,7 +5808,7 @@ export type UpdateWorkflow = {
5502
5808
  next: string | null;
5503
5809
  kind: 'branch';
5504
5810
  /**
5505
- * Name the answer is kept under, for a later `branch`.
5811
+ * Name the answer is kept under, for a later `decision` to compare as a `variable`.
5506
5812
  */
5507
5813
  answer_key?: string;
5508
5814
  /**