PreviewAPI version 0.4.0

Embed widget

Put a prompt and its record button on your own site with two lines of HTML.

The embed widget puts a prompt on your own web page: the question, a player for it if it was recorded, and a button a visitor presses to record a reply. Replies land in the podcaster's Vox Pop inbox like any other.

Get the code

In the Vox Pop dashboard, open a prompt, choose Share, and copy the code under Embed on a website. It looks like this:

HTML
<script src="https://embed.voxpop.audio/widget.js" defer></script>
<vox-pop-prompt handle="myshow" prompt-id="3mi5a5dynk2n3"></vox-pop-prompt>

Paste it where you want the recorder to appear. The script only needs to be on the page once, even if you embed several prompts.

To write it by hand, take the two values from the prompt's link. For https://voxpop.audio/@myshow/3mi5a5dynk2n3, handle is myshow and prompt-id is 3mi5a5dynk2n3.

Attributes

  • handle (required): the podcaster's handle, without the @.
  • prompt-id (required): the prompt's id, the last part of its link.
  • height: any CSS length, like 500px. Without it the widget is at least 600 pixels tall. It always fills the width of its container.
HTML
<vox-pop-prompt handle="myshow" prompt-id="3mi5a5dynk2n3" height="500px"></vox-pop-prompt>

The widget works best between 340 and 480 pixels wide. Changing an attribute after the page loads reloads the widget with the new prompt.

How it works

widget.js defines a <vox-pop-prompt> element. The element draws an iframe from https://embed.voxpop.audio, and the recording happens inside that iframe. It sets no cookies on your site and needs no API key.

Load the script from https://embed.voxpop.audio as shown. The widget works out where to point its iframe from the address the script was loaded from, so a copy hosted on your own server won't work.

The browser asks the visitor for microphone permission the first time they press record. If your site sends a Permissions-Policy header, it has to allow the microphone for https://embed.voxpop.audio.

After recording, the visitor confirms their phone number before the reply is sent. To do that the widget moves the whole tab to the prompt's page on https://voxpop.audio, so don't put the widget inside a sandboxed iframe of your own.

What the widget calls

Inside the iframe, the widget makes three requests to the Vox Pop API. None of them needs a key or a token, and each one is in the API reference under the same version rules as the rest of the API:

The widget makes no other calls to the API. The audio plays from the link in the prompt, and the reply is sent from the prompt's page once the visitor has confirmed their number.

Source code

The widget is open source under the MIT licence: bbthorson/vox-pop-embed on GitHub. That repository is a copy of the code that runs at https://embed.voxpop.audio, updated whenever it changes. Issues are welcome there.

Without JavaScript

Where you can't add a script tag, use a plain iframe. Keep allow="microphone", or the record button won't work. screen-wake-lock keeps a phone's screen from locking partway through a reply. Without it, a phone that locks mid-reply stops the recording.

HTML
<iframe
  src="https://embed.voxpop.audio/myshow/3mi5a5dynk2n3"
  width="400" height="600"
  allow="microphone; screen-wake-lock"
  style="border: 0"
></iframe>

Platforms that unfurl links can use oEmbed to get this iframe from a prompt link automatically.