set_message_sending_delay
Change how long the AI waits before sending an email reply, for one conversation.
set_message_sending_delay(context: dict, delay_min: int | None) -> dictOverrides how long the AI waits between composing a reply and sending it, for the current conversation. The override persists for the rest of the conversation and takes precedence over your account-level sending delay. It also applies to the reply the AI is generating right now, so you can set it from the same action or condition provider that decides it's needed.
A sending delay gives customers a grace window: if they write again before the delay elapses (adding details, correcting themselves, or sending a follow-up email), the queued reply is discarded and the AI composes a fresh one that takes the new message into account.
Only email conversations delay their sending. On other channels the override is stored but has no effect.
Parameters
| Name | Type | Description |
|---|---|---|
context | dict | The context object passed to your code |
delay_min | int or None | Minutes to wait before sending each reply. 0 sends immediately. Maximum 10080 (7 days). Pass None to clear the override and return to your account default. |
Returns
dict: {"success": bool, "message": str}
Behavior
- The override sticks for the whole conversation until it is changed again or cleared with
None. - It applies to the reply currently being generated, not just future ones.
- If the customer sends a new message before a queued reply goes out, that reply is discarded and a fresh one is generated instead. This includes a message that arrives while the reply is still being written. A queued reply that already performed an action, such as a refund, is sent instead of discarded, and the fresh reply follows it.
- Queued replies are not sent if the conversation is handed off to a human in the meantime.
- Each change is recorded in the conversation timeline, so you can see when and why the delay changed.
- In test/mock environments (no conversation attached), returns a mock success response without changing anything.
Examples
Give VIP customers instant replies
This reads a vip flag written earlier in the conversation, for example by an action that looked the customer up in your store with get_integration_credentials:
def execute_action(context):
is_vip = get_conversation_metadata(context, "vip") == "true"
if is_vip:
set_message_sending_delay(context, 0)
return {"success": True, "vip": is_vip}Slow down replies for conversations that need a cooling-off window
def evaluate_conditions(context):
is_legal_threat = llm_classify_binary(
"Does the customer threaten legal action or a chargeback?",
context["conversation"]["messages"][-1]["content"],
fallback=False,
)
if is_legal_threat:
# Hold replies for an hour so a human can review or the customer can cool off
set_message_sending_delay(context, 60)
return {"conditions": {"legal_threat": is_legal_threat}}