Skip to content
The Chat Archive
o1-preview-2024-09-12· OpenAI WildChat-4.8M (AI2)

this is is for a transient assistant in vapi, the code does not send the data via…

  1. User

    this is is for a transient assistant in vapi, the code does not send the data via webhook to the requested tool. I've checked the tool works when requested from an inbound static assistant. Can you fix it? https://docs.vapi.ai/api-reference/calls/create-call { "transcriber": { "provider": "deepgram", "model": "nova-2", "language": "en" }, "model": { "provider": "openai", "model": "gpt-4o", "temperature": 0.3, "messages": [ { "role": "system", "content": "# Role\n\nYou are Mary, a highly skilled representative working at Swiftleads AI, specializing in providing voice AI solutions for real estate businesses. You are known for your warm, welcoming attitude and excellent communication skills. Your role is to:\n\n- Greet clients and callers professionally with a friendly, approachable tone.\n- Respond accurately and helpfully to inquiries from potential clients interested in integrating voice AI into their real estate business.\n- Provide information about voice AI solutions, scheduling appointments, and services.\n- Assist with basic inquiries and direct more complex questions to the appropriate specialists or departments.\n- Use clear, simple language when speaking to ensure everyone understands, especially those unfamiliar with voice AI technology.\n- Maintain a calm and patient demeanor, especially when dealing with clients who may be new to AI technologies.\n- Build a sense of trust and connection with the clients you serve.\n\n# Cultural Considerations\n\n- Understand the dynamics of working with professionals in the real estate industry who are exploring new technologies.\n- Be mindful of the need for empathy, patience, and flexibility when communicating with clients from diverse backgrounds.\n- Use informal, conversational language that fits the professional setting, making interactions feel more relatable and comfortable.\n- Reflect an understanding of the importance of being approachable, respectful, and knowledgeable in all interactions.\n\n# Task\n\nYour task is to call leads who have recently filled out a form expressing interest in implementing voice AI into their real estate business. You will qualify them to see if they are ready, willing, and able to make an investment now, and set up appointments with a specialist if appropriate.\n\n# Specifics\n\n- [ CONDITION ] this is a condition block; use this to guide the conversation based on the intent of the user's answers.\n- <variable> is a variable block, which should always be substituted by the information the caller has provided.\n- You may only ask one question at a time.\n- Wait for a response after each question you ask.\n- If the caller has any inquiry that is out of the scope of the conversation, say you'll pass on the message to Parvez and that they'll be in touch.\n- When the user has answered the qualifying questions, set up an appointment for them to talk with the specialist.\n\n# Context\n\nYou are in a phone conversation with a lead who is interested in integrating voice AI into their real estate business.\n\n# Steps\n\n1. Greet the caller by name and confirm it's a good time to talk.\n\n - Q: "Hello, is this <Lead's Name>? This is Mary from Swiftleads AI. Is now a good time to talk?"\n\n2. Thank them for their interest and provide a brief introduction.\n\n - Q: "Great! I wanted to thank you for filling out our form expressing interest in our voice AI solutions for real estate businesses."\n\n3. Ask if they're currently using any AI or automation technologies.\n\n - Q: "Are you currently using any AI or automation technologies in your business?"\n\n4. Ask about their specific goals with voice AI.\n\n - Q: "What specific goals are you hoping to achieve with voice AI?"\n\n5. Ask how soon they're looking to implement a voice AI solution.\n\n - Q: "How soon are you looking to implement a voice AI solution?"\n\n6. Qualify their readiness to invest.\n\n - [ If the user is looking to implement within the next 6 months -> ]\n\n - Q: "Do you have a budget allocated for this investment?"\n\n - Q: "Are you the decision-maker for such investments in your company?"\n\n - [ If the user is not looking to implement soon -> ]\n\n - Q: "Would you like me to send you more information to review at your convenience?"\n\n7. Set up an appointment or provide next steps.\n\n - [ If the user is ready to proceed -> ]\n\n - Q: "Fantastic! I can set up an appointment with our specialist, Parvez, who can provide more details and answer any questions you might have. I just sent you an email with the booking link. Go ahead and follow the link; I'll stay on the line with you in case you need any assistance."\n\n - [ If the user is not ready to proceed -> ]\n\n - Q: "No problem at all. I'll send over some additional information via email. Feel free to reach out if you have any questions."\n\n8. Stay on the line to assist if needed.\n\n - Q: "Do you have any questions while we're on the call?"\n\n# Example Conversation\n\nQ = Question you ask, R = Caller response.\n\n## If the user is ready to invest now:\n\nQ: "Hello, is this <Lead's Name>? This is Mary from Swiftleads AI. Is now a good time to talk?"\n\nR: "Yes, this is <Lead's Name>. Sure, I have a few minutes."\n\nQ: "Great! I wanted to thank you for filling out our form expressing interest in our voice AI solutions for real estate businesses."\n\nQ: "Are you currently using any AI or automation technologies in your business?"\n\nR: "No, we haven't implemented any yet."\n\nQ: "What specific goals are you hoping to achieve with voice AI?"\n\nR: "I'm looking to improve client engagement and automate some of our customer service tasks."\n\nQ: "How soon are you looking to implement a voice AI solution?"\n\nR: "Ideally within the next three months."\n\nQ: "That's excellent! Do you have a budget allocated for this investment?"\n\nR: "Yes, we've set aside funds for this project."\n\nQ: "Are you the decision-maker for such investments in your company?"\n\nR: "Yes, I am."\n\nQ: "Fantastic! I can set up an appointment with our specialist, Parvez, who can provide more details and answer any questions you might have. I just sent you an email with the booking link. Go ahead and follow the link; I'll stay on the line with you in case you need any assistance."\n\nR: "Thank you, I'll check my email now."\n\nQ: "Great! Do you have any questions while we're on the call?"\n\nR: "No, I think that's all for now."\n\nQ: "Wonderful! We're excited to work with you. Have a fantastic day!"\n\n## If the user is not ready to invest now:\n\nQ: "Hello, is this <Lead's Name>? This is Mary from Swiftleads AI. Is now a good time to talk?"\n\nR: "I'm actually in the middle of something."\n\nQ: "I understand. Would there be a better time for a quick chat?"\n\nR: "Maybe later this week."\n\nQ: "Sure, I'd be happy to reach out then. Before I let you go, would you like me to send you some information via email to review at your convenience?"\n\nR: "Yes, please. That would be helpful."\n\nQ: "Great! I'll send that over shortly. Feel free to reach out if you have any questions. Have a wonderful day!"\n\n# Available Tools\n\n- getCurrentDateAndTime: Retrieves the current date and time.\n\n- sendBookingLink: Sends an email or text message with the booking link to the caller.\n\n# Notes\n\n- Use casual language with phrases like "Umm...", "Well...", and "I mean" to sound more natural.\n- The sendBookingLink tool will not return a success message, so assume that it succeeded.\n- Be enthusiastic, charming, and patient.\n- Only ask one question at a time and wait for the caller's response before proceeding.\n- Personalize the conversation by using the caller's name and referencing their specific interests.\n- If the caller asks a question outside the scope, say: "I'll pass on your message to Parvez, and they'll be in touch."\n- Use informal, conversational language that fits the professional setting, making interactions feel more relatable and comfortable.\n\n# Final Tips\n\n- Active Listening: Pay attention to the caller's responses and adjust your questions accordingly.\n- Respect Their Time: Keep the conversation concise and focused to respect the caller's time.\n- Stay Professional: While using casual language, remain professional and courteous.\n- Follow-Up: Ensure all promised actions, like sending emails or scheduling calls, are completed promptly.\n" } ], "tools": [ { "type": "function", "function": { "name": "getCurrentDateAndTime", "description": "Retrieves the current date and time", "parameters": { "type": "object", "properties": {} } } }, { "type": "function", "function": { "name": "sendBookingLink", "description": "Sends an email or text message with the booking link to the caller", "parameters": { "type": "object", "properties": { "recipient": { "type": "string", "description": "Email address or phone number of the recipient" }, "method": { "type": "string", "enum": ["email", "sms"], "description": "Method to send the booking link" } }, "required": ["recipient", "method"] } } } ] }, "voice": { "provider": "deepgram", "voiceId": "athena" }, "firstMessageMode": "assistant-speaks-first", "name": "Automated AI Cold Caller", "firstMessage": "Hello {{3.0}}, this is Mary from Swiftleads AI. You had filled our enquiry form and I'm reaching out to ask you a few questions. Is this a good time?", "recordingEnabled": true }

  2. Assistant

    Yes, I can help you fix this issue.

    Problem Explanation:

    When using a transient assistant in VAPI (Voiceflow API), you need to explicitly specify callback URLs for events like tool invocations (function calls). In your current configuration, the transient assistant is not sending data via webhook to the requested tool because the onFunctionCall callback URL is missing in your create-call request.

    In a static assistant, callbacks are often configured within the assistant's settings, so tool invocations are properly routed. However, for transient assistants, you must include these callbacks in the API request to ensure the assistant knows where to send the webhook data when a tool is invoked.


    Solution:

    To fix the issue, you need to add a callbacks object to your create-call JSON request, specifying the onFunctionCall URL. This tells the transient assistant where to send the data when a tool is invoked.

    Here's how you can modify your JSON code:

    {
      "transcriber": {
        "provider": "deepgram",
        "model": "nova-2",
        "language": "en"
      },
      "model": {
        "provider": "openai",
        "model": "gpt-4o",
        "temperature": 0.3,
        "messages": [
          {
            "role": "system",
            "content": "# Role\n\nYou are **Mary**, a highly skilled representative working at **Swiftleads AI**, specializing in providing voice AI solutions for real estate businesses. You are known for your warm, welcoming attitude and excellent communication skills. Your role is to:\n\n- Greet clients and callers professionally with a friendly, approachable tone.\n- Respond accurately and helpfully to inquiries from potential clients interested in integrating voice AI into their real estate business.\n- Provide information about voice AI solutions, scheduling appointments, and services.\n- Assist with basic inquiries and direct more complex questions to the appropriate specialists or departments.\n- Use clear, simple language when speaking to ensure everyone understands, especially those unfamiliar with voice AI technology.\n- Maintain a calm and patient demeanor, especially when dealing with clients who may be new to AI technologies.\n- Build a sense of trust and connection with the clients you serve.\n\n# Cultural Considerations\n\n- Understand the dynamics of working with professionals in the real estate industry who are exploring new technologies.\n- Be mindful of the need for empathy, patience, and flexibility when communicating with clients from diverse backgrounds.\n- Use informal, conversational language that fits the professional setting, making interactions feel more relatable and comfortable.\n- Reflect an understanding of the importance of being approachable, respectful, and knowledgeable in all interactions.\n\n# Task\n\nYour task is to call leads who have recently filled out a form expressing interest in implementing voice AI into their real estate business. You will qualify them to see if they are ready, willing, and able to make an investment now, and set up appointments with a specialist if appropriate.\n\n# Specifics\n\n- **[ CONDITION ]** this is a condition block; use this to guide the conversation based on the intent of the user's answers.\n- `<variable>` is a variable block, which should always be substituted by the information the caller has provided.\n- You may only **ask one question at a time**.\n- **Wait for a response** after each question you ask.\n- If the caller has any inquiry that is **out of the scope** of the conversation, say you'll pass on the message to **Parvez** and that they'll be in touch.\n- When the user has answered the qualifying questions, set up an appointment for them to talk with the specialist.\n\n# Context\n\nYou are in a phone conversation with a lead who is interested in integrating voice AI into their real estate business.\n\n# Steps\n\n1. **Greet the caller by name and confirm it's a good time to talk.**\n\n   - **Q:** \"Hello, is this `<Lead's Name>`? This is **Mary** from **Swiftleads AI**. Is now a good time to talk?\"\n\n2. **Thank them for their interest and provide a brief introduction.**\n\n   - **Q:** \"Great! I wanted to thank you for filling out our form expressing interest in our voice AI solutions for real estate businesses.\"\n\n3. **Ask if they're currently using any AI or automation technologies.**\n\n   - **Q:** \"Are you currently using any AI or automation technologies in your business?\"\n\n4. **Ask about their specific goals with voice AI.**\n\n   - **Q:** \"What specific goals are you hoping to achieve with voice AI?\"\n\n5. **Ask how soon they're looking to implement a voice AI solution.**\n\n   - **Q:** \"How soon are you looking to implement a voice AI solution?\"\n\n6. **Qualify their readiness to invest.**\n\n   - **[ If the user is looking to implement within the next 6 months -> ]**\n\n     - **Q:** \"Do you have a budget allocated for this investment?\"\n\n     - **Q:** \"Are you the decision-maker for such investments in your company?\"\n\n   - **[ If the user is not looking to implement soon -> ]**\n\n     - **Q:** \"Would you like me to send you more information to review at your convenience?\"\n\n7. **Set up an appointment or provide next steps.**\n\n   - **[ If the user is ready to proceed -> ]**\n\n     - **Q:** \"Fantastic! I can set up an appointment with our specialist, **Parvez**, who can provide more details and answer any questions you might have. I just sent you an email with the booking link. Go ahead and follow the link; I'll stay on the line with you in case you need any assistance.\"\n\n   - **[ If the user is not ready to proceed -> ]**\n\n     - **Q:** \"No problem at all. I'll send over some additional information via email. Feel free to reach out if you have any questions.\"\n\n8. **Stay on the line to assist if needed.**\n\n   - **Q:** \"Do you have any questions while we're on the call?\"\n\n# Example Conversation\n\n**Q = Question you ask, R = Caller response.**\n\n## If the user is ready to invest now:\n\n**Q:** \"Hello, is this `<Lead's Name>`? This is **Mary** from **Swiftleads AI**. Is now a good time to talk?\"\n\n**R:** \"Yes, this is `<Lead's Name>`. Sure, I have a few minutes.\"\n\n**Q:** \"Great! I wanted to thank you for filling out our form expressing interest in our voice AI solutions for real estate businesses.\"\n\n**Q:** \"Are you currently using any AI or automation technologies in your business?\"\n\n**R:** \"No, we haven't implemented any yet.\"\n\n**Q:** \"What specific goals are you hoping to achieve with voice AI?\"\n\n**R:** \"I'm looking to improve client engagement and automate some of our customer service tasks.\"\n\n**Q:** \"How soon are you looking to implement a voice AI solution?\"\n\n**R:** \"Ideally within the next three months.\"\n\n**Q:** \"That's excellent! Do you have a budget allocated for this investment?\"\n\n**R:** \"Yes, we've set aside funds for this project.\"\n\n**Q:** \"Are you the decision-maker for such investments in your company?\"\n\n**R:** \"Yes, I am.\"\n\n**Q:** \"Fantastic! I can set up an appointment with our specialist, **Parvez**, who can provide more details and answer any questions you might have. I just sent you an email with the booking link. Go ahead and follow the link; I'll stay on the line with you in case you need any assistance.\"\n\n**R:** \"Thank you, I'll check my email now.\"\n\n**Q:** \"Great! Do you have any questions while we're on the call?\"\n\n**R:** \"No, I think that's all for now.\"\n\n**Q:** \"Wonderful! We're excited to work with you. Have a fantastic day!\"\n\n## If the user is not ready to invest now:\n\n**Q:** \"Hello, is this `<Lead's Name>`? This is **Mary** from **Swiftleads AI**. Is now a good time to talk?\"\n\n**R:** \"I'm actually in the middle of something.\"\n\n**Q:** \"I understand. Would there be a better time for a quick chat?\"\n\n**R:** \"Maybe later this week.\"\n\n**Q:** \"Sure, I'd be happy to reach out then. Before I let you go, would you like me to send you some information via email to review at your convenience?\"\n\n**R:** \"Yes, please. That would be helpful.\"\n\n**Q:** \"Great! I'll send that over shortly. Feel free to reach out if you have any questions. Have a wonderful day!\"\n\n# Available Tools\n\n- **getCurrentDateAndTime**: Retrieves the current date and time.\n\n- **sendBookingLink**: Sends an email or text message with the booking link to the caller.\n\n# Notes\n\n- Use casual language with phrases like \"Umm...\", \"Well...\", and \"I mean\" to sound more natural.\n- The **sendBookingLink** tool will not return a success message, so assume that it succeeded.\n- Be enthusiastic, charming, and patient.\n- Only ask **one question at a time** and **wait for the caller's response** before proceeding.\n- Personalize the conversation by using the caller's name and referencing their specific interests.\n- If the caller asks a question outside the scope, say: \"I'll pass on your message to **Parvez**, and they'll be in touch.\"\n- Use informal, conversational language that fits the professional setting, making interactions feel more relatable and comfortable.\n\n# Final Tips\n\n- **Active Listening:** Pay attention to the caller's responses and adjust your questions accordingly.\n- **Respect Their Time:** Keep the conversation concise and focused to respect the caller's time.\n- **Stay Professional:** While using casual language, remain professional and courteous.\n- **Follow-Up:** Ensure all promised actions, like sending emails or scheduling calls, are completed promptly.\n"
          }
        ],
        "tools": [
          {
            "type": "function",
            "function": {
              "name": "getCurrentDateAndTime",
              "description": "Retrieves the current date and time",
              "parameters": {
                "type": "object",
                "properties": {}
              }
            }
          },
          {
            "type": "function",
            "function": {
              "name": "sendBookingLink",
              "description": "Sends an email or text message with the booking link to the caller",
              "parameters": {
                "type": "object",
                "properties": {
                  "recipient": {
                    "type": "string",
                    "description": "Email address or phone number of the recipient"
                  },
                  "method": {
                    "type": "string",
                    "enum": ["email", "sms"],
                    "description": "Method to send the booking link"
                  }
                },
                "required": ["recipient", "method"]
              }
            }
          }
        ]
      },
      "voice": {
        "provider": "deepgram",
        "voiceId": "athena"
      },
      "firstMessageMode": "assistant-speaks-first",
      "name": "Automated AI Cold Caller",
      "firstMessage": "Hello {{3.`0`}}, this is Mary from Swiftleads AI. You had filled our enquiry form and I'm reaching out to ask you a few questions. Is this a good time?",
      "recordingEnabled": true,
      "callbacks": {
        "onFunctionCall": "https://your-webhook-url.com/handle-function-call"
      }
    }
    

    Explanation:

    • Added the callbacks object: This includes the onFunctionCall property set to your webhook URL (https://your-webhook-url.com/handle-function-call). Replace this with your actual webhook URL where you want to receive the tool invocation data.

      "callbacks": {
        "onFunctionCall": "https://your-webhook-url.com/handle-function-call"
      }
      

    Next Steps:

    1. Update Your Request:

      • Include the callbacks object in your create-call request as shown above.
    2. Ensure Your Webhook Endpoint is Ready:

      • Make sure that the webhook URL you provide (https://your-webhook-url.com/handle-function-call) is correctly set up to receive POST requests from VAPI.
      • It should be accessible over the internet (publicly reachable) and configured to handle and parse the incoming JSON data.
    3. Handle the Incoming Tool Invocation:

      • When the assistant invokes a tool (e.g., sendBookingLink), VAPI will send a POST request to your onFunctionCall endpoint with the tool's name and parameters.
      • Your server should process this data, perform the necessary actions (e.g., sending an email or SMS), and respond appropriately.
    4. Test the Setup:

      • Place a test call to verify that the assistant is now sending the tool invocation data to your webhook.
      • Check your server logs to ensure that you are receiving the data and that your endpoint is processing it as expected.

    Additional Information:

    • Understanding Callbacks:

      • The callbacks property in the create-call request allows you to specify URLs for various events. In this case, onFunctionCall is used to receive data when a tool is invoked by the assistant.
      • For more details, you can refer to the VAPI documentation on callbacks.
    • Example of Incoming Webhook Data:

      • When a tool is invoked, VAPI will send a payload similar to:

        {
          "callID": "your-call-id",
          "tool": {
            "name": "sendBookingLink",
            "parameters": {
              "recipient": "caller@example.com",
              "method": "email"
            }
          },
          "timestamp": "2023-10-06T12:34:56Z"
        }
        
    • Responding to the Webhook:

      • Your endpoint should return a response indicating success or failure.
      • Typically, you might return a 200 OK status code to acknowledge receipt.
    • Security Considerations:

      • It's recommended to implement authentication on your webhook endpoint to ensure that only authorized requests from VAPI are processed.
      • You can use methods like verifying a shared secret, checking request headers, or whitelisting VAPI IP addresses.

    Summary:

    By adding the onFunctionCall callback URL in your create-call request, you're instructing the transient assistant where to send the data when a tool is invoked. This should resolve the issue of the data not being sent via webhook to the requested tool.

    Let me know if you need further assistance!