getricky 0.1.41 → 0.1.43

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.
3322
- */
3323
- trigger: 'at_time' | 'conversation_assigned' | 'conversation_inactive' | 'conversation_opened' | 'first_message_received' | 'message_received' | 'message_sent' | 'team_message_unanswered' | 'call_received';
3324
- /**
3325
- * Channels it listens to. See `GET /channels`.
3326
- */
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.
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.
3330
3450
  */
3331
- inactivity_seconds?: number;
3451
+ trigger: 'conversation_opened' | 'first_message_received' | 'message_received' | 'message_sent' | 'conversation_inactive' | 'team_message_unanswered' | 'schedule' | 'conversation_assigned' | 'call_received';
3332
3452
  /**
3333
- * Which messages a `message_received` workflow reacts to.
3453
+ * Whether an occurrence of the trigger runs the workflow; null runs every occurrence on every channel.
3334
3454
  */
3335
- message_filters?: {
3336
- /**
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
- };
3455
+ condition: Condition | null;
3362
3456
  /**
3363
- * When an `at_time` workflow runs; required for it and only for it.
3457
+ * When a `schedule` workflow runs; required for it and only for it.
3364
3458
  */
3365
- at_time?: {
3366
- /**
3367
- * Quarter hour it runs, `HH:MM`.
3368
- */
3369
- time: string;
3459
+ schedule?: {
3370
3460
  /**
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.
3465
+ * Each time and its days; each time of each day at most once.
3376
3466
  */
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`.
3385
- */
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.
3561
+ * Branches in the order they are checked; the first that holds is taken.
3481
3562
  */
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.
3494
- */
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.
@@ -3962,6 +4040,24 @@ export type WhatsAppNumber = {
3962
4040
  profile_picture_url: string | null;
3963
4041
  };
3964
4042
  };
4043
+ export type WorkflowMutation = Workflow | {
4044
+ /**
4045
+ * Workflow ID.
4046
+ */
4047
+ id: string;
4048
+ /**
4049
+ * Display name.
4050
+ */
4051
+ name: string;
4052
+ /**
4053
+ * `draft` until activated; `paused` runs nothing new; `active` runs.
4054
+ */
4055
+ status: 'draft' | 'active' | 'paused';
4056
+ /**
4057
+ * Last change to the workflow.
4058
+ */
4059
+ updated_at: string;
4060
+ };
3965
4061
  /**
3966
4062
  * How the handoff ends.
3967
4063
  */
@@ -4880,6 +4976,10 @@ export type UpdateKnowledgeFile = {
4880
4976
  * The file every send of the workflow carries in its template header.
4881
4977
  */
4882
4978
  export type UploadWorkflowHeaderMedia = {
4979
+ /**
4980
+ * Copy updated_at from the workflow you read. A concurrent change returns 409 conflict.
4981
+ */
4982
+ expected_updated_at?: string;
4883
4983
  /**
4884
4984
  * Public HTTPS address Ricky downloads the file from. It must not redirect or resolve to a private address, and its `Content-Type` must be the kind the template header takes (image, video or document) within WhatsApp’s size limit for it.
4885
4985
  */
@@ -5007,6 +5107,134 @@ export type BusinessHoursInput = {
5007
5107
  */
5008
5108
  weekdays?: Array<number>;
5009
5109
  };
5110
+ /**
5111
+ * A yes-or-no question: a comparison of one field, or a group. Each trigger offers its own fields; a `decision` also reads `variable`.
5112
+ */
5113
+ export type ConditionInput = {
5114
+ kind: 'compare';
5115
+ field: 'assignee';
5116
+ /**
5117
+ * `is` holds for any of `values`; `is_not` for none.
5118
+ */
5119
+ operator: 'is' | 'is_not';
5120
+ /**
5121
+ * Who has the conversation: a member, an agent or nobody.
5122
+ */
5123
+ values: Array<{
5124
+ kind: 'person';
5125
+ /**
5126
+ * A member. See `GET /members`.
5127
+ */
5128
+ user_id: string;
5129
+ } | {
5130
+ kind: 'agent';
5131
+ /**
5132
+ * An AI agent.
5133
+ */
5134
+ agent_id: string;
5135
+ } | {
5136
+ kind: 'nobody';
5137
+ }>;
5138
+ } | {
5139
+ kind: 'compare';
5140
+ field: 'conversation_status';
5141
+ /**
5142
+ * `is` holds for any of `values`; `is_not` for none.
5143
+ */
5144
+ operator: 'is' | 'is_not';
5145
+ /**
5146
+ * Open or closed.
5147
+ */
5148
+ values: Array<'open' | 'closed'>;
5149
+ } | {
5150
+ kind: 'compare';
5151
+ field: 'ai';
5152
+ /**
5153
+ * `is` holds for any of `values`; `is_not` for none.
5154
+ */
5155
+ operator: 'is' | 'is_not';
5156
+ /**
5157
+ * `on` while an AI agent answers the conversation, as its assignee or with the AI on in it.
5158
+ */
5159
+ values: Array<'on' | 'off'>;
5160
+ } | {
5161
+ kind: 'compare';
5162
+ field: 'channel';
5163
+ /**
5164
+ * `is` holds for any of `values`; `is_not` for none.
5165
+ */
5166
+ operator: 'is' | 'is_not';
5167
+ /**
5168
+ * Channels. See `GET /channels`.
5169
+ */
5170
+ values: Array<string>;
5171
+ } | {
5172
+ kind: 'compare';
5173
+ field: 'time';
5174
+ /**
5175
+ * Whether the moment of evaluation is within the hours or outside them.
5176
+ */
5177
+ operator: 'within' | 'outside';
5178
+ business_hours: BusinessHoursInput;
5179
+ } | {
5180
+ kind: 'compare';
5181
+ field: 'message_first';
5182
+ /**
5183
+ * `is` when the contact wrote first in the conversation, before any message from the business.
5184
+ */
5185
+ operator: 'is' | 'is_not';
5186
+ } | {
5187
+ kind: 'compare';
5188
+ field: 'message_type';
5189
+ /**
5190
+ * `is` holds for any of `values`; `is_not` for none.
5191
+ */
5192
+ operator: 'is' | 'is_not';
5193
+ /**
5194
+ * The kind of message; `button` is a tapped button or list option on any channel.
5195
+ */
5196
+ values: Array<'text' | 'button' | 'image' | 'audio' | 'video' | 'document' | 'location' | 'sticker' | 'other'>;
5197
+ } | {
5198
+ kind: 'compare';
5199
+ field: 'message_text';
5200
+ operator: 'contains' | 'not_contains';
5201
+ /**
5202
+ * Compared ignoring case, accents and repeated spaces.
5203
+ */
5204
+ value: string;
5205
+ } | {
5206
+ kind: 'compare';
5207
+ field: 'message_sender';
5208
+ /**
5209
+ * `is` holds for any of `values`; `is_not` for none.
5210
+ */
5211
+ operator: 'is' | 'is_not';
5212
+ /**
5213
+ * 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).
5214
+ */
5215
+ values: Array<'person' | 'ai' | 'automation' | 'broadcast' | 'external_app'>;
5216
+ } | {
5217
+ kind: 'compare';
5218
+ field: 'variable';
5219
+ /**
5220
+ * The `answer_key` an earlier `ask_question` step saved.
5221
+ */
5222
+ name: string;
5223
+ operator: 'is' | 'is_not' | 'contains' | 'not_contains' | 'exists' | 'not_exists';
5224
+ /**
5225
+ * Compared ignoring case and accents; absent for `exists` and `not_exists`.
5226
+ */
5227
+ value?: string;
5228
+ } | {
5229
+ /**
5230
+ * `all` holds when every condition holds; `any` when at least one does.
5231
+ */
5232
+ kind: 'all' | 'any';
5233
+ /**
5234
+ * Comparisons or groups, three levels deep at most.
5235
+ */
5236
+ conditions: Array<ConditionInput>;
5237
+ };
5010
5238
  /**
5011
5239
  * Creates a conversation workflow as a `draft`. Activating it is a separate call.
5012
5240
  */
@@ -5016,23 +5244,55 @@ export type CreateWorkflow = {
5016
5244
  */
5017
5245
  name: string;
5018
5246
  /**
5019
- * Reacts to a conversation with messages, questions, waits and assignments.
5247
+ * Reacts to a conversation with messages, questions, decisions, waits and assignments.
5020
5248
  */
5021
5249
  definition: {
5022
5250
  /**
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.
5251
+ * 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
5252
  */
5025
- trigger: 'at_time' | 'conversation_assigned' | 'conversation_inactive' | 'conversation_opened' | 'first_message_received' | 'message_received' | 'message_sent' | 'team_message_unanswered' | 'call_received';
5253
+ trigger: 'conversation_opened' | 'first_message_received' | 'message_received' | 'message_sent' | 'conversation_inactive' | 'team_message_unanswered' | 'schedule' | 'conversation_assigned' | 'call_received' | 'at_time';
5026
5254
  /**
5027
- * Channels it listens to. See `GET /channels`.
5255
+ * Whether an occurrence of the trigger runs the workflow; null runs every occurrence on every channel.
5028
5256
  */
5029
- channel_ids: Array<string>;
5257
+ condition: ConditionInput | {
5258
+ kind: 'inside_business_hours';
5259
+ business_hours: BusinessHoursInput;
5260
+ } | {
5261
+ kind: 'outside_business_hours';
5262
+ business_hours: BusinessHoursInput;
5263
+ } | null;
5264
+ /**
5265
+ * When a `schedule` workflow runs; required for it and only for it.
5266
+ */
5267
+ schedule?: {
5268
+ /**
5269
+ * IANA time zone of every time.
5270
+ */
5271
+ timezone: string;
5272
+ /**
5273
+ * Each time and its days; each time of each day at most once.
5274
+ */
5275
+ times: Array<{
5276
+ /**
5277
+ * Quarter hour it runs, `HH:MM`.
5278
+ */
5279
+ time: string;
5280
+ /**
5281
+ * Days it runs at that time, 0 for Sunday to 6 for Saturday.
5282
+ */
5283
+ weekdays: Array<number>;
5284
+ }>;
5285
+ };
5030
5286
  /**
5031
5287
  * 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
5288
  */
5033
5289
  inactivity_seconds?: number;
5034
5290
  /**
5035
- * Which messages a `message_received` workflow reacts to.
5291
+ * Deprecated: read as a `channel` comparison in `condition`.
5292
+ */
5293
+ channel_ids?: Array<string>;
5294
+ /**
5295
+ * Deprecated, requests only: read as `condition` comparisons on `message_first`, `assignee` (nobody) and `message_type` (not `button`).
5036
5296
  */
5037
5297
  message_filters?: {
5038
5298
  /**
@@ -5049,7 +5309,7 @@ export type CreateWorkflow = {
5049
5309
  skip_buttons: boolean;
5050
5310
  };
5051
5311
  /**
5052
- * Which outgoing messages a `message_sent` workflow reacts to; required for it.
5312
+ * Deprecated, requests only: read as `condition` comparisons on `message_sender` and `message_text`.
5053
5313
  */
5054
5314
  sent_message_filters?: {
5055
5315
  /**
@@ -5062,7 +5322,7 @@ export type CreateWorkflow = {
5062
5322
  text_contains?: string;
5063
5323
  };
5064
5324
  /**
5065
- * When an `at_time` workflow runs; required for it and only for it.
5325
+ * Deprecated, requests only: an `at_time` workflow is read as `schedule` with this one time.
5066
5326
  */
5067
5327
  at_time?: {
5068
5328
  /**
@@ -5079,7 +5339,7 @@ export type CreateWorkflow = {
5079
5339
  weekdays: Array<number>;
5080
5340
  };
5081
5341
  /**
5082
- * Which conversations `at_time` and `conversation_assigned` reach; only for them.
5342
+ * Deprecated, requests only: read as `condition` comparisons on `assignee` and `conversation_status`.
5083
5343
  */
5084
5344
  conversation_filters?: {
5085
5345
  /**
@@ -5091,16 +5351,6 @@ export type CreateWorkflow = {
5091
5351
  */
5092
5352
  only_open: boolean;
5093
5353
  };
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
5354
  /**
5105
5355
  * The steps and how they connect.
5106
5356
  */
@@ -5141,7 +5391,7 @@ export type CreateWorkflow = {
5141
5391
  */
5142
5392
  text: string;
5143
5393
  /**
5144
- * Name the answer is kept under, for a later `branch`.
5394
+ * Name the answer is kept under, for a later `decision` to compare as a `variable`.
5145
5395
  */
5146
5396
  answer_key: string;
5147
5397
  /**
@@ -5173,6 +5423,34 @@ export type CreateWorkflow = {
5173
5423
  * Step to run when the answer matches no option.
5174
5424
  */
5175
5425
  on_invalid: string | null;
5426
+ } | {
5427
+ /**
5428
+ * Step ID: letters, digits, `_` or `-`, up to 64.
5429
+ */
5430
+ id: string;
5431
+ kind: 'decision';
5432
+ /**
5433
+ * Branches in the order they are checked; the first that holds is taken.
5434
+ */
5435
+ branches: Array<{
5436
+ /**
5437
+ * Step ID: letters, digits, `_` or `-`, up to 64.
5438
+ */
5439
+ id: string;
5440
+ /**
5441
+ * Branch name, unique in the decision.
5442
+ */
5443
+ name: string;
5444
+ condition: ConditionInput;
5445
+ /**
5446
+ * Step to run when this branch is the first whose condition holds.
5447
+ */
5448
+ next: string | null;
5449
+ }>;
5450
+ /**
5451
+ * Step to run when no branch holds («Si no»); null ends the flow.
5452
+ */
5453
+ next: string | null;
5176
5454
  } | {
5177
5455
  /**
5178
5456
  * Step ID: letters, digits, `_` or `-`, up to 64.
@@ -5184,7 +5462,7 @@ export type CreateWorkflow = {
5184
5462
  next: string | null;
5185
5463
  kind: 'branch';
5186
5464
  /**
5187
- * Name the answer is kept under, for a later `branch`.
5465
+ * Name the answer is kept under, for a later `decision` to compare as a `variable`.
5188
5466
  */
5189
5467
  answer_key?: string;
5190
5468
  /**
@@ -5329,6 +5607,10 @@ export type CreateWorkflow = {
5329
5607
  * Only the fields you send change. The status stays: an active workflow runs the new definition from its next execution.
5330
5608
  */
5331
5609
  export type UpdateWorkflow = {
5610
+ /**
5611
+ * Copy updated_at from the workflow you read. A concurrent change returns 409 conflict.
5612
+ */
5613
+ expected_updated_at?: string;
5332
5614
  /**
5333
5615
  * Display name.
5334
5616
  */
@@ -5338,19 +5620,51 @@ export type UpdateWorkflow = {
5338
5620
  */
5339
5621
  definition?: {
5340
5622
  /**
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.
5623
+ * 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
5624
  */
5343
- trigger: 'at_time' | 'conversation_assigned' | 'conversation_inactive' | 'conversation_opened' | 'first_message_received' | 'message_received' | 'message_sent' | 'team_message_unanswered' | 'call_received';
5625
+ trigger: 'conversation_opened' | 'first_message_received' | 'message_received' | 'message_sent' | 'conversation_inactive' | 'team_message_unanswered' | 'schedule' | 'conversation_assigned' | 'call_received' | 'at_time';
5344
5626
  /**
5345
- * Channels it listens to. See `GET /channels`.
5627
+ * Whether an occurrence of the trigger runs the workflow; null runs every occurrence on every channel.
5346
5628
  */
5347
- channel_ids: Array<string>;
5629
+ condition: ConditionInput | {
5630
+ kind: 'inside_business_hours';
5631
+ business_hours: BusinessHoursInput;
5632
+ } | {
5633
+ kind: 'outside_business_hours';
5634
+ business_hours: BusinessHoursInput;
5635
+ } | null;
5636
+ /**
5637
+ * When a `schedule` workflow runs; required for it and only for it.
5638
+ */
5639
+ schedule?: {
5640
+ /**
5641
+ * IANA time zone of every time.
5642
+ */
5643
+ timezone: string;
5644
+ /**
5645
+ * Each time and its days; each time of each day at most once.
5646
+ */
5647
+ times: Array<{
5648
+ /**
5649
+ * Quarter hour it runs, `HH:MM`.
5650
+ */
5651
+ time: string;
5652
+ /**
5653
+ * Days it runs at that time, 0 for Sunday to 6 for Saturday.
5654
+ */
5655
+ weekdays: Array<number>;
5656
+ }>;
5657
+ };
5348
5658
  /**
5349
5659
  * 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
5660
  */
5351
5661
  inactivity_seconds?: number;
5352
5662
  /**
5353
- * Which messages a `message_received` workflow reacts to.
5663
+ * Deprecated: read as a `channel` comparison in `condition`.
5664
+ */
5665
+ channel_ids?: Array<string>;
5666
+ /**
5667
+ * Deprecated, requests only: read as `condition` comparisons on `message_first`, `assignee` (nobody) and `message_type` (not `button`).
5354
5668
  */
5355
5669
  message_filters?: {
5356
5670
  /**
@@ -5367,7 +5681,7 @@ export type UpdateWorkflow = {
5367
5681
  skip_buttons: boolean;
5368
5682
  };
5369
5683
  /**
5370
- * Which outgoing messages a `message_sent` workflow reacts to; required for it.
5684
+ * Deprecated, requests only: read as `condition` comparisons on `message_sender` and `message_text`.
5371
5685
  */
5372
5686
  sent_message_filters?: {
5373
5687
  /**
@@ -5380,7 +5694,7 @@ export type UpdateWorkflow = {
5380
5694
  text_contains?: string;
5381
5695
  };
5382
5696
  /**
5383
- * When an `at_time` workflow runs; required for it and only for it.
5697
+ * Deprecated, requests only: an `at_time` workflow is read as `schedule` with this one time.
5384
5698
  */
5385
5699
  at_time?: {
5386
5700
  /**
@@ -5397,7 +5711,7 @@ export type UpdateWorkflow = {
5397
5711
  weekdays: Array<number>;
5398
5712
  };
5399
5713
  /**
5400
- * Which conversations `at_time` and `conversation_assigned` reach; only for them.
5714
+ * Deprecated, requests only: read as `condition` comparisons on `assignee` and `conversation_status`.
5401
5715
  */
5402
5716
  conversation_filters?: {
5403
5717
  /**
@@ -5409,16 +5723,6 @@ export type UpdateWorkflow = {
5409
5723
  */
5410
5724
  only_open: boolean;
5411
5725
  };
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
5726
  /**
5423
5727
  * The steps and how they connect.
5424
5728
  */
@@ -5459,7 +5763,7 @@ export type UpdateWorkflow = {
5459
5763
  */
5460
5764
  text: string;
5461
5765
  /**
5462
- * Name the answer is kept under, for a later `branch`.
5766
+ * Name the answer is kept under, for a later `decision` to compare as a `variable`.
5463
5767
  */
5464
5768
  answer_key: string;
5465
5769
  /**
@@ -5491,6 +5795,34 @@ export type UpdateWorkflow = {
5491
5795
  * Step to run when the answer matches no option.
5492
5796
  */
5493
5797
  on_invalid: string | null;
5798
+ } | {
5799
+ /**
5800
+ * Step ID: letters, digits, `_` or `-`, up to 64.
5801
+ */
5802
+ id: string;
5803
+ kind: 'decision';
5804
+ /**
5805
+ * Branches in the order they are checked; the first that holds is taken.
5806
+ */
5807
+ branches: Array<{
5808
+ /**
5809
+ * Step ID: letters, digits, `_` or `-`, up to 64.
5810
+ */
5811
+ id: string;
5812
+ /**
5813
+ * Branch name, unique in the decision.
5814
+ */
5815
+ name: string;
5816
+ condition: ConditionInput;
5817
+ /**
5818
+ * Step to run when this branch is the first whose condition holds.
5819
+ */
5820
+ next: string | null;
5821
+ }>;
5822
+ /**
5823
+ * Step to run when no branch holds («Si no»); null ends the flow.
5824
+ */
5825
+ next: string | null;
5494
5826
  } | {
5495
5827
  /**
5496
5828
  * Step ID: letters, digits, `_` or `-`, up to 64.
@@ -5502,7 +5834,7 @@ export type UpdateWorkflow = {
5502
5834
  next: string | null;
5503
5835
  kind: 'branch';
5504
5836
  /**
5505
- * Name the answer is kept under, for a later `branch`.
5837
+ * Name the answer is kept under, for a later `decision` to compare as a `variable`.
5506
5838
  */
5507
5839
  answer_key?: string;
5508
5840
  /**
@@ -7846,7 +8178,7 @@ export type DeleteWorkflowResponses = {
7846
8178
  * Success.
7847
8179
  */
7848
8180
  200: {
7849
- data: Workflow;
8181
+ data: WorkflowMutation;
7850
8182
  };
7851
8183
  };
7852
8184
  export type DeleteWorkflowResponse = DeleteWorkflowResponses[keyof DeleteWorkflowResponses];
@@ -7937,6 +8269,8 @@ export type UpdateWorkflowErrors = {
7937
8269
  * `idempotency_conflict`: The `Idempotency-Key` was used for a different request.
7938
8270
  *
7939
8271
  * `request_processing`: A request with this `Idempotency-Key` is still processing or ended in an unknown state.
8272
+ *
8273
+ * `conflict`: The resource changed in a way that prevents the operation.
7940
8274
  */
7941
8275
  409: Error;
7942
8276
  /**
@@ -8064,7 +8398,7 @@ export type PauseWorkflowResponses = {
8064
8398
  * Success.
8065
8399
  */
8066
8400
  200: {
8067
- data: Workflow;
8401
+ data: WorkflowMutation;
8068
8402
  };
8069
8403
  };
8070
8404
  export type PauseWorkflowResponse = PauseWorkflowResponses[keyof PauseWorkflowResponses];
@@ -8168,6 +8502,8 @@ export type UploadWorkflowHeaderMediaErrors = {
8168
8502
  * `idempotency_conflict`: The `Idempotency-Key` was used for a different request.
8169
8503
  *
8170
8504
  * `request_processing`: A request with this `Idempotency-Key` is still processing or ended in an unknown state.
8505
+ *
8506
+ * `conflict`: The resource changed in a way that prevents the operation.
8171
8507
  */
8172
8508
  409: Error;
8173
8509
  /**