# Creating an agent

When you sign up for Simple Phones, you are prompted to create an AI agent. Fill out the form with your business name, description, and website, and click Create. The agent will use this information to answer basic questions from callers. This is just to start out. Its knowledge base can be expanded later on. More on that in the [Crawl](/basics/crawling) section.

On the Basic plan, you can create one agent, but if you have a need for multiple languages, or want to create an agent for multiple business, or even have multiple international numbers for the same agent, you can upgrade and get set up at any time.


# Inbound Calls

When you create an agent, it is assigned a random phone number. If someone calls that number, the agent will answer with a default greeting, and present several options to the caller, such as "book a call" or "leave a message". If the caller says one of those options, the call will be directed down the corresponding flow. For example, if the caller says "leave a message", the call will go down the "leave a message" flow, asking for their name and message, and then redirecting them back to the main menu once the flow is complete.

If the caller says something else that is not one of the flows, the utterance will be passed to OpenAI's GPT-3, which is pre-prompted with the information about your business that was supplied when the agent was created.

Ultimately, these initial options, and whether or not to use GPT-3 as a fallback, is all customizable. You can submit a "change request" in your dashboard to make changes to, additions to, or remove any of these things.


# Outbound Calls

As calls come in to your agent, you can go to your dashboard to click on a call from the call list. Once on the call detail page, you can see the start time, end time, duration, and transcript. From there, you click on the phone number of your agent to go to the number detail page, OR you can click on the phone number of the caller to open up the Outbound Call modal.

Once in the Outbound Call modal, on top you'll see the "To" number, which will be pre-populated with the number you clicked on to open the modal. Below that, you'll see the caller ID which they'll see when you start the call. Below that, you'll be presented with two options: connect the callee with your personal phone, or connect them with one of your AI agents.

If you choose to connect the callee with your personal phone, and you click Start Call, you will receive a call on your personal phone. When you answer, it will then ring the "To" number. Don't worry, the callee will see the caller ID that was indicated in the modal, not your personal number.

If you choose to connect the callee with one of your AI agents, your personal phone will not receive a call. Instead, the callee will receive a call right away. Once they answer, it will be connected with the agent, and the greeting will start from there, just like an inbound call.

By default, outbound calls are limited to one call per "To" number per 24 hour period, and you can only call a number if they called you first. To get around this restriction, you can add your own Twilio account in your account settings. Once added, outbound calls will originate from your Twilio account, and there will be no restrictions from Simple Phones on who you can call or how often.


# Routing

By default, if a caller says something like "Speak to a live representative", the agent will tell them to leave a message. But this, as you may have guessed, is customizable. The agent can instead be programmed to forward to the call onto any other number. Just let us know what number to forward the call to, and we will add it in. The agent can also check things like the time of day or day of week, before deciding whether or not to transfer the call. It can even ask for the caller's first name before deciding to forward the call based on the letter of the alphabet their name starts with.

Emails, texts, or webhooks can also be sent to your back end, which can be helpful in alerting your team members to the needs of your callers. For example, if you're running a brokerage, and a caller says they're interested in buying a home, the agent can gather the buyer's info, and send a text message to the phone number of your star real estate agent so they can follow up right away.


# Crawling

At any time, you can request a crawl of your website or FAQ documents. We will load the information gained from the crawl into your AI agent, so that it will retrieve the most relevant piece of content to refer to when the GPT-3 fallback is used to answer a random utterance from a caller.

For example, if a caller asks "How much does Simple Phones cost?" and the website was not crawled, the AI agent will just provide the general prompt about Simple Phones to GPT-3 (the one that was written when the agent was created) and so it will probably give an inaccurate answer. To fix this, once information from the website is loaded in, GPT-3 will automatically be prompted with the section of the website related to pricing, using a semantic search of the entire knowledge base, so it will give a much more accurate answer, in a comparable amount of time.


# What are webhooks?

Imagine you have a toy mailbox in your room, and sometimes your friends send you letters or small gifts. Normally, you would have to wait by the mailbox and check if there's anything new. But what if the mailbox could let you know as soon as something arrives?

Well, that's kind of how webhooks work. Instead of waiting and checking if something happened on a website or app, webhooks are like special signals that get sent to you automatically whenever something important occurs. It's like the website or app is saying, "Hey, something new happened! Come and see!"

Just like your mailbox needs to know your address to send you things, webhooks need to know where to send the signals. You set up a special address, like your email or phone number, and tell the website or app to send the signals there.

So whenever something happens on Simple Phones, like a new message or call, it sends a signal to your special address. Then you can quickly know that something happened without having to keep checking all the time.


# Get started with webhooks

To set up a webhook with Simple Phones:

1. Try our webhook simulator here: <https://www.simplephones.ai/webhooks>
2. Let us know (1) your webhook URL, and (2) the info that you would like to receive. For example, a call transcript, or a new message that someone left.

Check out some cool integrations you can do with Simple Phones webhooks + Zapier here: <https://zapier.com/apps/webhook/integrations>


# Authentication

To view or reset your API key, go to your account settings at simplephones.ai/settings

For all API requests, include your API key in the `Authorization` header like so:

```
Authorization: Bearer <API KEY>
```


# List of Numbers

This endpoint will retrieve a list of up to 100 of the latest created numbers for your account:

```
GET https://api.simplephones.ai/v1/numbers/user
```

Example return value:

```
[
  {
    _id: '64211d3f0c7bc80023ca863c',
    user: 'ddc6e69e5e97ec915cf9b23f',
    rawNumber: '+15555555555',
    formattedNumber: '(555) 555-5555',
    language: 'en',
    created: '2023-03-01T12:00:00.000Z',
    lastCall: '2023-03-01T12:00:00.000Z'
  }
]
```


# List of Calls

This endpoint will retrieve a list of up to 100 of the latest calls for your account:

```
GET https://api.simplephones.ai/v1/calls/user
```

Example return value:

```
[
  {
    _id: '819d7067dbd62ca62a6c62c5',
    minutesUsed: 0.9666666666666667,
    user: '47630a2e0efa1ae21f848a69',
    number: 'c2d525c7c7b5b9f1fd941770',
    fromRawNumber: '+17777777777',
    fromFormattedNumber: '(777) 777-7777',
    toRawNumber: '+15555555555',
    toFormattedNumber: '(555) 555-5555',
    startTime: '2023-03-01T13:00:00.000Z',
    endTime: '2023-03-01T13:01:01.000Z',
    transcript: [
      {
        _id: '87a6ba747dc1625be5b12562',
        who: 'agent',
        message: 'Hello, this is Smith Notary. How can I help you today? You can say things like, "about us", "schedule an appointment" or "leave a message".',
        created: '2023-03-01T13:00:00.000Z'
      },
      {
        _id: '5f9a2eec8cad59afe6efe0e2',
        who: 'user',
        message: 'leave a message',
        created: '2023-03-01T13:01:00.000Z'
      },
      {
        _id: '9d0ecd3f6345dc7f52c7acd0',
        who: 'agent',
        message: 'Got it.',
        created: '2023-03-01T13:01:00.000Z'
      }
    ],
    created: '2023-03-01T13:03:00.000Z',
  }
]
```


# Call Details & Transcript

This endpoint will retrieve the call details for a specific call:

```
GET https://api.simplephones.ai/v1/calls/:callId
```

To obtain the callId, try getting a list of your latest calls. (see previous page)

Example return value:

```
{
  _id: '819d7067dbd62ca62a6c62c5',
  minutesUsed: 0.9666666666666667,
  user: '47630a2e0efa1ae21f848a69',
  number: 'c2d525c7c7b5b9f1fd941770',
  fromRawNumber: '+17777777777',
  fromFormattedNumber: '(777) 777-7777',
  toRawNumber: '+15555555555',
  toFormattedNumber: '(555) 555-5555',
  startTime: '2023-03-01T13:00:00.000Z',
  endTime: '2023-03-01T13:01:01.000Z',
  transcript: [
    {
      _id: '87a6ba747dc1625be5b12562',
      who: 'agent',
      message: 'Hello, this is Smith Notary. How can I help you today? You can say things like, "about us", "schedule an appointment" or "leave a message".',
      created: '2023-03-01T13:00:00.000Z'
    },
    {
      _id: '5f9a2eec8cad59afe6efe0e2',
      who: 'user',
      message: 'leave a message',
      created: '2023-03-01T13:01:00.000Z'
    },
    {
      _id: '9d0ecd3f6345dc7f52c7acd0',
      who: 'agent',
      message: 'Got it.',
      created: '2023-03-01T13:01:00.000Z'
    }
  ],
  created: '2023-03-01T13:03:00.000Z',
}
```


# Outbound Call

This endpoint will initiate an outbound call:

```
POST https://api.simplephones.ai/v1/twilio/outbound

Body for connecting to agent:

{
    numberId: 'c2d525c7c7b5b9f1fd941770',
    callTo: '+15555555555'
}

Body for connecting to personal phone:

{
    callFrom: '+17777777777',
    callTo: '+15555555555'
}
```

'callTo' and 'callFrom' must be in E. 164 format, as shown above.

To obtain the numberId, try getting a list of your numbers. (see [List of Numbers](/developers/list-of-numbers))

To enable this endpoint for your account, please contact <support@simplephones.ai>.


