Graine AI

Workflows

startWorkflow on every platform — start one of your outreach workflows for the user your app signed in, with the fields the workflow allows; what it returns, retries and errors. Requires SDK 0.14.4.

Your app can start one of your outreach workflows for the user it signed in — a welcome call after sign-up, a follow-up after an order — with no server of yours. The workflow must have Your app can start this turned on, on its Connect tab (Start from your app).

Requires SDK 0.14.4

iOS, Android, Kotlin Multiplatform and Flutter 0.14.4, React Native 0.47.3 and the website loader 1.5.0.

startWorkflow

Starts a run of the workflow for the identified customer.

client.startWorkflow(workflow: string, data?: Record<string, string | number | boolean>, options?: { idempotencyKey?: string }): Promise<GraineWorkflowRun>
 
const { runId } = await client.startWorkflow("Welcome call", { plan: "gold" });
ParameterTypeRequiredLimits
workflowStringYes120 charactersThe workflow's exact name, or its id (owf_…)
dataAn objectNoAt most 12 values, each text (200 characters), a number or yes/noThe contact fields the workflow allows (its Connect tab). Anything else is left out, never refused — and never a phone number, an email address or another field a step sends to
idempotencyKeyStringNo8 to 128 letters, digits, _, -, . or :Two calls with the same key start one run. Leave it out and the SDK makes one for the call, and uses it again when it retries a request that got no answer

The run is for the user your app signed in — call identify() with the agent's identity trait first. Their ID becomes the run's entry.user_id; a user_id (or reference_id) in data is ignored.

Where the run sends is never your app's to choose. A mobile_number, email or other field a step sends to is left out of data. A user the agent knows by phone or email, and verified, is reached at that number or address.

Returns a GraineWorkflowRun:

{ "runId": "oex_2c9e8f1a7b3d4c5e6f7a8b9c", "workflowId": "owf_8a1d4e7c2b90f1a2b3c4d5e6", "alreadyRunning": false }

alreadyRunning is true when the user already had a run of this workflow under way: you get that run, never a second one.

Resolves when the run has started (or the run already under way was found).

Errors on the device: identity_required when nobody is identified, invalid_request for a missing workflow name. From Graine:

CodeMeans
not_allowedNo such workflow, or Your app can start this is off for it, or it isn't published yet
identity_requiredNobody is signed in with the agent's identity trait
not_verifiedThis device isn't one of the user's signed-in devices (Devices per user), or the agent requires a verified user
identity_unverifiedRequire verified users is on and this user isn't verified: pass the identity token from your sign-in to identify()
app_not_allowedOnly my apps is on and this app isn't one of your apps
app_not_verifiedRequire a verified app is on and this app hasn't proved it is yours
rate_limitedToo many starts from this device or for this user (an hour), or of this workflow (a minute) — wait retryAfterSeconds
unavailableThe workspace can't start it right now: no credit, or the workflow's agent is switched off
invalid_requestThe workflow needs a field your app didn't send (and may not send)
networkNo answer: try again with the same idempotencyKey

See Errors.

On this page