Launch flow
Opening Twofold from your UI on the right provider, patient and appointment.
Recording starts in Twofold, not in your product — but you decide who is recording, about whom, and against which appointment. That is what the launch URL is for.
https://app.trytwofold.com/launch
?externalUserId=provider-1042
&patientExternalId=client-2048
¬eExternalId=appointment-9
&returnUrl=https%3A%2F%2Fapp.example.com%2Fappointments%2F9https://app.staging.trytwofold.com/launch
?externalUserId=provider-1042
&patientExternalId=client-2048
¬eExternalId=appointment-9
&returnUrl=https%3A%2F%2Fapp.example.com%2Fappointments%2F9| Parameter | |
|---|---|
externalUserId | Required. The provider this session belongs to. |
patientExternalId | Optional. Locks the recording to this patient — upsert the patient before sending the provider over. |
noteExternalId | Optional. Your appointment id; it is stamped on the note that gets recorded and comes back in every webhook and note payload. |
returnUrl | Optional. An absolute URL, URL-encoded, to send the provider back to once they end the recording — see Back to your product after the recording. |
Open it from a button in your UI. On desktop, open it in a new tab so the provider keeps your page behind it.
What the provider sees
The right provider, in the right account. externalUserId is verified against the Twofold account that is signed in. If someone else is signed in — a shared computer, a personal account, a second Twofold login — Twofold blocks the launch and offers to switch accounts rather than recording into the wrong chart.
The patient, already selected — and locked. If patientExternalId matches a patient you have upserted for this provider, it is preselected and cannot be switched, so the recording lands on exactly the patient you sent them for. If it matches nothing yet, Twofold waits — polling until the patient appears — and opens the recording screen the moment it does. Upsert the patient before (or as) you open the launch URL, and the wait is never visible. Without a patientExternalId, the provider picks a patient as usual.
Nothing recorded automatically. The launch page never starts a recording on its own — the provider presses record when the session actually begins. The parameters are consumed at that moment, so a second recording started later from the same tab is not silently stamped with your appointment id.
When the provider presses your button again
Open the launch URL one of two ways: in a new, unnamed tab every time, or by navigating your own page to it. For a new tab:
window.open(launchUrl, "_blank");window.open(launchUrl, "_blank");Never load the launch URL into a tab you opened earlier, and don't give the tab a name, as in window.open(launchUrl, "twofold"), because a named tab gets reused. If that tab is a Twofold tab that is recording, loading the URL reloads it and the reload stops the recording. The provider lands on an empty record screen while their session carries on, and nothing more is captured.
So a second press opens a second Twofold tab. If another Twofold tab already has a recording, the launch page shows a dialog with the time that recording started and whether it is running or paused. The provider can press Close this tab and switch to the recording tab themselves, or press Record in this tab to close the dialog and record in the new tab. Nothing is blocked. Providers often keep one tab recording and others open to review or prepare notes.
Close this tab reliably closes the tab when your page opened it with window.open. On a tab opened any other way, it may only close the dialog.
Neither Twofold nor your product can bring the recording tab to the front. Browsers don't let a page focus another tab, even one on the same site, which is why the dialog asks the provider to switch tabs themselves.
Back to your product after the recording
With a returnUrl, ending the recording takes the provider back to you. After they press End, Twofold shows that the recording is being saved and that they will be taken back to you, waits until Twofold has received all of the audio and started generating the note — usually a few seconds — and then navigates the tab to your returnUrl. The provider can choose to stay in Twofold instead while it waits.
Twofold waits for the upload on purpose: a tab that navigates away before the audio is uploaded leaves the note ungenerated until the provider next opens Twofold.
It is the Twofold tab itself that navigates to your returnUrl. If you opened the launch URL in a new tab, the provider ends up with two tabs of your product. To have them land back where they started, navigate your own page to the launch URL instead of opening a new tab. On a page opened that way, Close this tab in the other-tab dialog only closes the dialog.
Only a recording started from the launch page, and ended with End, sends the provider back. Discarding the recording, or leaving it paused, does not. Without a returnUrl, the provider stays in Twofold after End, as before.
Setting it up. Add the host your returnUrl points to — app.example.com, with no scheme, port or path — under Return URL hosts on the partner console's settings page, in each environment you use, before you pass returnUrl. Hosts are matched exactly, ignoring case: example.com does not cover app.example.com. Only the host is compared, so a port in the returnUrl itself is fine. A returnUrl must be https; on staging, http://localhost also works once localhost is listed. A returnUrl whose host is not listed is ignored silently: the provider can still record, and simply stays in Twofold afterwards.
Web only, for now. The Twofold native app does not send the provider back yet, and ignores returnUrl.
Mobile
On phones, the production launch URL opens the Twofold native app — that is the main way providers use Twofold in a session, and the flow is identical once inside: same account check, same preselected patient, same manual record.
Two things to know:
- If the app is not installed, the provider is sent to the App Store or Play Store. After installing, they return to your product and tap the launch button again — there is no deferred hand-off that survives the install.
- Testing the app on staging. A staging build of the iOS app is available through TestFlight. Contact us to be added to its testing group. Without it, mobile browsers on staging get the web recorder, so the whole flow is still testable end to end.
Putting it together
A typical appointment in your product:
- The provider is linked (once, through consent).
- When the appointment is created or opened, you
PUTthe patient — so Twofold has them under yourpatientExternalId. - The provider presses your "Record with Twofold" button, which opens the launch URL with all three parameters.
note.startedarrives when they begin recording;note.generated_successfullywhen the note is ready.- You fetch the note by its
noteId, route its sections bysectionExternalId, and store it against your appointment — which you recognise fromnoteExternalId.
Remember that a noteExternalId can appear on more than one note: a provider who records an appointment twice produces two notes carrying the same value. Fetch by noteId from the webhook, and treat "notes for this appointment" as a list.