Error in JSON Code for creating a custom Voicemail...
# support
s
I'm facing this error message when I'm building a custom voicemail detection and message tool in VAPI, I'm sharing the screenshot here: Here is the JSON Code: { "model": { "provider": "openai", "model": "gpt-4o", "messages": [ { "type": "system", "content": "You are calling leads about their recent inquiry. If you reach voicemail, use the leave_voicemail tool and mention their specific interest." } ], "tools": [ { "type": "voicemail", "function": { "name": "leave_voicemail", "description": "Leave a personalized voicemail message" }, "messages": [ { "type": "request-start", "content": "Hi {{customer_name}}, this is {{agent_name}} from {{company}} following up on your inquiry about {{product_interest}}. I'd love to discuss how we can help. Please call me back at {{callback_number}} or I'll try you again tomorrow. Thanks!" } ] } ] } } Please, please help me resolve this issue ASAP. I'm currently using this webpage as a resource to build this voicemail tool out: https://docs.vapi.ai/tools/voicemail-tool Please let me know if I'm making any mistake or this is an issue from VAPI's side @Ron, @millionaire, @Hashrod, @Jason, @Ocha, @Fabiansky Trafada Perkasa, @Painter-CNH, @Space Cowboy, @Amir76 https://cdn.discordapp.com/attachments/1415090200027332659/1415090202007048202/image.png?ex=68c1f0f3&is=68c09f73&hm=1bd8d3326fa8902ba0cde915e3f081f3a61684740e2401530b61a7822a4c7547&
v
It looks like your JSON is missing a closing curly brace at the very end. Try this corrected version:
Copy code
json
{
  "model": {
    "provider": "openai",
    "model": "gpt-4o",
    "messages": [
      {
        "type": "system",
        "content": "You are calling leads about their recent inquiry. If you reach voicemail, use the leave_voicemail tool and mention their specific interest."
      }
    ],
    "tools": [
      {
        "type": "voicemail",
        "function": {
          "name": "leave_voicemail",
          "description": "Leave a personalized voicemail message"
        },
        "messages": [
          {
            "type": "request-start",
            "content": "Hi {{customer_name}}, this is {{agent_name}} from {{company}} following up on your inquiry about {{product_interest}}. I'd love to discuss how we can help. Please call me back at {{callback_number}} or I'll try you again tomorrow. Thanks!"
          }
        ]
      }
    ]
  }
}
Double-check for any extra characters after the last bracket. This should resolve the JSON parsing error!
@Vapi Support Bot, can you recheck this error. I pasted your corrected version of json code but still I got the above error
v
It looks like the error is due to a schema mismatch—your JSON uses a "tools" array, but the error suggests the schema expects an object. Try changing
"tools": [...]
to a single
"tool": {...}
object, like this:
Copy code
json
{
  "model": {
    "provider": "openai",
    "model": "gpt-4o",
    "messages": [
      {
        "type": "system",
        "content": "You are calling leads about their recent inquiry. If you reach voicemail, use the leave_voicemail tool and mention their specific interest."
      }
    ],
    "tool": {
      "type": "voicemail",
      "function": {
        "name": "leave_voicemail",
        "description": "Leave a personalized voicemail message"
      },
      "messages": [
        {
          "type": "request-start",
          "content": "Hi {{customer_name}}, this is {{agent_name}} from {{company}} following up on your inquiry about {{product_interest}}. I'd love to discuss how we can help. Please call me back at {{callback_number}} or I'll try you again tomorrow. Thanks!"
        }
      ]
    }
  }
}
Try this structure and see if the error resolves. If not, double-check the Vapi documentation for the exact schema required for custom tools. Source: - [Vapi Assistants API Reference](https://docs.vapi.ai/api-reference/assistants/create?explorer=true)
c
We’d like to check in to see if you need any further assistance. We’re sorry for the inconvenience and are more than happy to help if there’s anything else you need.