When someone dials in to a phone number instead of routing the person to a specific room or call (usually identified by PIN Code), in the pinless dialin, a new room is created and the Daily Bot joins that room. If someone re-dials the phone number, they will be connected to a new room.

This can be achieved in two ways:

  1. Use Daily to initialize the bot
  2. Provide a webhook url from your application infrastructure to initialize it

Either way begins with the purchase of a phone number, so let’s start there.

Purchase a phone number

To buy a random phone number, make a POST request with no data field, the response will return a random phone number:

curl --request POST \
  --url 'https://api.daily.co/v1/buy-phone-number' \
  --header 'Authorization: Bearer $TOKEN' \
  --header 'Content-Type: application/json'

Alternatively, if you are looking for a particular number, you can search for the available numbers and buy a specific number of your choosing, if it is available.

Use Daily to initialize a bot

After purchasing a phone number, click on the Add Configuration button on the right hand side of the number.

Choose the Daily: provide your configuration option.

Add a prompt and adjust your settings as you wish.

And that’s it. Call the number and talk to your new bot.

Use a custom application webhook to initialize a bot

Choose the Self-hosted: provide a webhook URL option.

The workflow is as follows:

  1. Configure the phone number for Pinless dial-in
  2. When a phone call is received on Daily, Daily will trigger a webhook ($DIALIN_URL) to your application infrastructure. Meanwhile the call is put on hold and the end user will hear hold music
  3. Within the webhook, your app will set up the RTVI config and services and call Daily’s https://api.daily.co/v1/bots/start
  4. When the bot joins the call, the end-user is forwarded to the call and should hear the bot speak shortly after joining.

Things to have handy:

  • Your account’s API Key
  • Your hosted application’s URL ($DIALIN_URL), the URL should contain the path that will receive the dial-in webhook from Daily, for example, https://www.example.com/api/dialin. See our tutorial on Dial-in for more details.

Setting up a Pinless Dial-in phone number

The pinless dial-in will invoke an HTTP call to your infrastructure, which would then call Daily’s /bot/start endpoint. The $DIALIN_URL is triggered when a call is received on the phone_number. The pinless_dialin configuration is set on your Daily domain and sets up the first part of that workflow, i.e., connecting the phone number to the $DIALIN_URL.

curl --request POST \
--location 'https://api.daily.co/v1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $TOKEN' \
--data '{
    "properties": {
        "pinless_dialin": [{
            "phone_number":"+19499870006",
            "room_creation_api": "$DIALIN_URL"
        }]
    }
}'

pinless_dialin is an array that can contain forwarding rules for several phone_numbers. These phone numbers can map to the same room_creation_api or different URLs.

If you have configured multiple phone numbers, make note that the all phone_numbers should be present when updating a single phone_number. The API does not do partial array updates, i.e., a POST request will override the existing pinless_dialin array with the new value. Hence, to keep existing routes, you should them all.

How does it work

Daily triggers a POST request to the URL specified by the room_creation_api in the pinless_dialin configuration (e.g., $DIALIN_URL). The following payload is received at the $DIALIN_URL:

// data received on the webhook, map it to `dialin_settings`
{
  "From": "+CALLERS_PHONE",
  "To": "$NUMBER",
  "callId": "callid-read-only-string",
  "callDomain": "callDomain-read-only-string"
}

Your server-side application will have to construct the appropriate bot config and call /bot/start:

const payload = {
  bot_profile: defaultBotProfile,
  services: defaultServices,
  api_keys: {
    together: TOGETHER_API_KEY,
    cartesia: CARTESIA_API_KEY,
  },
  config: defaultConfig,
  dialin_settings: {
    callId,
    callDomain,
  },
  max_duration: defaultMaxDuration,
};

Finally, when you call the phone number, you will initially hear the hold music until the bot connects. The bot should start speaking immediately after the call connects.

Voila, you now have a bot that responds to dial-in calls!