Building a bot that dials out to a phone number or a SIP address.

The workflow is as follows:

  • Buy a phone numbers, if you already have a number you can reuse it for dial-out.
  • Set the phoneNumber or sipUri to be dialed within the dialout_settings and send the config to /bot/start
  • The bot will automatically dial the phoneNumber or the sipUri

Structure of dialout_settings

dialout_settings allows dialing out to several phone numbers or SIP URIs. Hence, it is an arry of objects. Each object contains either phoneNumber or sipUri key.

[{"phoneNumber": "+123456789"}]

[{"sipUri": "sip:+123456789@daily-twilio-interconnect.sip.twilio.com"}]

The payload to /bot/start is as follows:

{
  "bot_profile": "voice_2024_10",
  "dialout_settings": [{ "phoneNumber": "+123456789" }],
  "max_duration": 300,
  "services": {
    "tts": "cartesia",
    "llm": "anthropic"
  },
  "config": [
    {
      "service": "tts",
      "options": [
        {
          "name": "voice",
          "value": "79a125e8-cd45-4c13-8a67-188112f4dd22"
        }
      ]
    },
    {
      "service": "llm",
      "options": [
        {
          "name": "model",
          "value": "claude-3-5-sonnet-latest"
        },
        {
          "name": "initial_messages",
          "value": [
            {
              "role": "user",
              "content": [
                {
                  "type": "text",
                  "text": "You are an assistant called Daily Bot. You can ask me anything. Keep responses brief and legible. Introduce yourself first."
                }
              ]
            }
          ]
        },
        {
          "name": "run_on_config",
          "value": true
        }
      ]
    }
  ]
}

Dial out to a phone

As an example, for developers familiar with the daily-bots-web-demo, we have added /api/dialout endpoint. If you are running the sample application locally, you can use cURL as follows to initiate dialing out:

curl --location --request POST 'http://localhost:3000/api/dialout' \
--header 'Content-Type: application/json' \
--data '[{"phoneNumber": "+123456789"}]'

The daily-bots-web-demo would then call /bot/start with dialout_settings set. The Daily bot on receiving the Bot config would start dialing out when the bot joins the Daily Room, the call will be connected when the Phone user picks up the phone.

Use SIP to dial out to Twilio

On Twilio, you will need to configure a SIP domain (e.g., daily-twilio-interconnect.sip.twilio.com) that invokes a TwiML Bin or a webhook when an incoming call is received on the configuredd SIP domain.

An example of a TwiML bin is as follows:

<Response>
    <Dial>
        <Number>{{#e164}}{{To}}{{/e164}}</Number>
    </Dial>
</Response>

The TwiML will parse out the phone number present in the username position in the SIP URI and dial it.

curl --location --request POST 'https://demo.dailybots.ai/api/dialout' \
--header 'Content-Type: application/json' \
--data '[{"sipUri": "sip:+17868748498@daily-twilio-interconnect.sip.twilio.com"}]'

You are now all set up to Dial out!