> ## Documentation Index
> Fetch the complete documentation index at: https://protegee.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Vapi

> Integration steps for Vapi

## Integration

### Collecting Payment

<Steps>
  <Step title="Create tools">
    In VAPI, you'll need to create the `SendContextToProtegee` and `GetContextFromProtegee` tools in order to let your agent interact with Protegee. Don't worry, all this requires from you is to press a button.

    You'll want to grab your VAPI private api key. It will look like:

    <img className="block" src="https://mintcdn.com/protegee/hyzol41G7875b8OT/images/vapi-api-key.png?fit=max&auto=format&n=hyzol41G7875b8OT&q=85&s=d946b5ed6f70bd572261d6642db5a4c6" width="1092" height="438" data-path="images/vapi-api-key.png" />

    Once you have that, you can run the following curl command (but replace `my_protegee_api_token` and `my_vapi_private_key` with the correct keys)

    <CodeGroup>
      ```bash cURL theme={null}
      curl --request POST \
      --url 'https://protegee.ai/voice/api/v1/vapi/create_tools?api_token=my_protegee_api_token' \
      --header 'Content-Type: application/json' \
      --data '{
      "vapi_key": "my_vapi_private_key"
      }'
      ```

      ```python Python theme={null}
      import requests

      url = "https://protegee.ai/voice/api/v1/vapi/create_tools"

      querystring = {"api_token":"my_protegee_api_token"}

      payload = {"vapi_key": "my_vapi_private_key"}
      headers = {"Content-Type": "application/json"}

      response = requests.request("POST", url, json=payload, headers=headers, params=querystring)

      print(response.text)
      ```

      ```java Java theme={null}
      const options = {
      method: 'POST',
      headers: {'Content-Type': 'application/json'},
      body: '{"vapi_key":"my_vapi_private_key"}'
      };

      fetch('https://protegee.ai/voice/api/v1/vapi/create_tools?api_token=my_protegee_api_token', options)
      .then(response => response.json())
      .then(response => console.log(response))
      .catch(err => console.error(err));
      ```
    </CodeGroup>

    You can also manually try out the endpoint by checking out: [VAPI Create Tools](http://localhost:3000/api-reference/endpoint/create-tools_vapi)
  </Step>

  <Step title="Setup forwarding phone number + Enable SendContextFromProtegee">
    On Assistant 1's function page, make sure `SendContextFromProtegee` is selected from the dropdown and the forwarding phone number is set to Protegee's number (you can this at [settings](https://protegee.ai/settings)).

    <img className="block" src="https://mintcdn.com/protegee/hyzol41G7875b8OT/images/vapi-setup-forwarding.png?fit=max&auto=format&n=hyzol41G7875b8OT&q=85&s=d2df9101a409601ef598b335b7e38ced" alt="Hero Light" width="2982" height="1588" data-path="images/vapi-setup-forwarding.png" />
  </Step>

  <Step title="Prompt your agent to call SendContextToProtegee tool + transfer the call">
    This lets Protegee know who to handle the payment for and how much. Something similar to:

    <Card title="Agent Instructions" icon="robot" horizontal>
      <li>Send the details to Protegee with the tool SendContextToProtegee, including all fields
      requested by SendContextToProtegee</li>
      <li>Let the caller know you need to take a \$25 deposit to confirm the appointment, and ask
      them to let you know when they're ready with their credit card</li>
      <li>Transfer the caller to Protegee at the saved transfer phone number. Just tell the caller
      to hang on one sec while you get the secure payment process ready.</li>
    </Card>
  </Step>

  <Step title="Give it a shot">
    If you have any issues, check out the [debug](https://protegee.ai/debug) page for more information.
  </Step>
</Steps>

### Checking on the status of the payment

The following instructions are OPTIONAL. If you specified a number in the `callback` field, [Protegee](https://protegee.ai) will transfer the caller back to this number once the payment process is complete. In order to continue the call, you'll want to make a webhook to get details on how the call went. The following are instructions on how to do that.

<Steps>
  <Step title="Setup a callback agent">
    If you'd like the caller to be transferred back from Protegee, make a second agent and enable `GetContextFromProtegee` on the agent's Functions page.
  </Step>

  <Step title="Enable GetContextFromProtegee tool call for the agent">
    On Assistant 1's function page, make sure `SendContextFromProtegee` is selected from the dropdown and the forwarding phone number is set to Protegee's number (you can this at [settings](https://protegee.ai/settings)).

    <img className="block" src="https://mintcdn.com/protegee/hyzol41G7875b8OT/images/vapi-add-get-context-tool.png?fit=max&auto=format&n=hyzol41G7875b8OT&q=85&s=316e93a06ac8d58dc69c630a55fa85a7" alt="Hero Light" width="2486" height="1570" data-path="images/vapi-add-get-context-tool.png" />
  </Step>

  <Step title="Prompt your agent to check the status">
    You can add something like this to Agent 2's prompt.

    <Card title="Agent Prompt" icon="robot" horizontal>
      After you greet the caller with the first message, immediately call the
      GetContextFromProtegee function and read back the response to the caller.
      Then ask if there's anything else you can help with.
      If they wish to book an appointment, your goal is to gather necessary information from
      callers in a friendly and efficient manner like follows…
    </Card>
  </Step>

  <Step title="Try it out!">
    If you have any issues, check out the [debug](https://protegee.ai/debug) page for more information.
  </Step>
</Steps>
