server-sdk-python: Couldn't Get Phone Number. Need...
# support
o
I am currently integrating vapi-client-sdk for the frontend and vapi-server-sdk-python for the backend in my application. I am encountering an issue where the backend server cannot start a conversation. Despite providing the assistantId, the API still responds with an error requiring either a phoneNumberId or phoneNumber. I have attached the relevant code for the backend route below. Could you please advise why the API might be asking for these parameters even when an assistantId is provided? Thank you in advance for your help! https://cdn.discordapp.com/attachments/1311179715868098711/1311179715985408021/python-vapi.py?ex=6747eac4&is=67469944&hm=9b9c53f434e96801e357f2ae7a47ac43e3283ffa0bde34779ab382278de88fe0&
@Vapi
v
@OlehSavchuk Certainly! It sounds like you're trying to initiate a conversation using VAPI, and you're encountering an issue where the API is expecting a
phoneNumberId
or
phoneNumber
even though you're providing an
assistantId
. The
assistantId
is typically used when you want to connect to a virtual assistant or bot, while
phoneNumberId
or
phoneNumber
is used when you want to connect to a specific phone number. To assist you better, I would need to see the actual code snippet you're using to start the conversation. This will help me understand how you're calling the API and why it might be expecting different parameters. Please provide the code snippet where you're setting up the conversation request, and I'll do my best to guide you through resolving this issue. If you have any error messages or logs, those would also be helpful in diagnosing the problem.
@Vapi ??
v
@OlehSavchuk I apologize for the confusion. It seems there might have been a misunderstanding. To proceed, please provide the code snippet you mentioned earlier that is causing the issue with starting a conversation on the backend using the
vapi-server-sdk-python
. Once I have the relevant code, I'll be able to offer more specific advice on how to resolve the problem you're encountering.
o
@app.route("/api/start-call", methods=["POST"]) def start_call(): try: data = request.json assistant_options = data.get("assistantOptions", {}).copy() if not assistant_options: return jsonify({"error": "Assistant options are required"}), 400 assistant_options.pop('assistantId', None) session = client.calls.create( assistant={ "name": assistant_options.get("name"), "firstMessage": assistant_options.get("firstMessage"), "transcriber": assistant_options.get("transcriber"), "voice": assistant_options.get("voice"), "model": assistant_options.get("model") } ) return jsonify({ "status": "success", "session_id": session.id, "message": session.first_message }) except Exception as e: return jsonify({"error": "Unexpected error occurred", "details": str(e)}), 500
@Vapi did you get a chance to see the code snippet?
v
@OlehSavchuk Yes, I've reviewed the code snippet you provided for starting a call using the
vapi-server-sdk-python
. From what you've described and the code you've shared, it seems like the
assistantId
is being removed from the
assistant_options
before making the API call:
Copy code
python
assistant_options.pop('assistantId', None)
This line of code is popping the
assistantId
out of the options, which means it's not being used in the
client.calls.create
method. The
assistantId
is necessary for the API to know which assistant to connect to. If you're trying to use an assistant, you should not remove the
assistantId
from the options. Instead, you should include the
assistantId
in the
assistant
parameter of the
client.calls.create
method. Here's how you might adjust the code:
Copy code
python
session = client.calls.create(
    assistant={
        "id": assistant_options.get("assistantId"),  # Include the assistantId here
        "name": assistant_options.get("name"),
        "firstMessage": assistant_options.get("firstMessage"),
        "transcriber": assistant_options.get("transcriber"),
        "voice": assistant_options.get("voice"),
        "model": assistant_options.get("model")
    }
)
Make sure that the
assistantId
is correctly provided in the
assistantOptions
in the request body and that it corresponds to a valid assistant in your system. Please try this adjustment and see if it resolves the issue. If you continue to face problems, it may be helpful to check the API documentation for the
vapi-server-sdk-python
to ensure that all required parameters are being passed correctly and that there are no additional configuration steps missing.
o
with such kind of code I get next error message: "details": "status_code: 400, body: {'message': ['assistant.property id should not exist'], 'error': 'Bad Request', 'statusCode': 400}", code snippet: session = client.calls.create( assistant={ "id": assistant_options.get("assistantId"), # Include the assistantId here "name": assistant_options.get("name"), "firstMessage": assistant_options.get("firstMessage"), "transcriber": assistant_options.get("transcriber"), "voice": assistant_options.get("voice"), "model": assistant_options.get("model") } )
v
@OlehSavchuk The error message you're receiving indicates that the
assistant
object should not contain an
id
property. This suggests that the API is expecting a different format for specifying the assistant. Based on the error message, it seems that the API is expecting either a
phoneNumberId
or
phoneNumber
to start a call, and not an
assistantId
within the
assistant
object. The
assistant
object might be used for specifying the configuration of the assistant, such as its
name
,
firstMessage
,
transcriber
,
voice
, and
model
, but not for identifying it by an
id
. If you are trying to specify which assistant to use by its ID, you may need to refer to the documentation for the correct way to do this. It's possible that the
assistantId
should be passed as a separate parameter outside of the
assistant
object, or that there's a different method or endpoint for initiating a call with an assistant by ID. Please check the documentation for the
vapi-server-sdk-python
or the API reference provided by the service to find the correct way to start a call with an assistant by its ID. If the documentation is not clear or you're unable to find the information you need, you might need to reach out to the API provider's support for further assistance. If you have access to the API documentation or can share more details about the expected parameters, I can help you construct the correct API call.
o
what kind of support are you? I asked for a help because the API documentation is not clear regarding server-sdk and you are referencing me back to the documentation
v
@OlehSavchuk I apologize for the inconvenience. It seems there might be a misunderstanding in the API's expected parameters for initiating a call with an assistant. Let's try to address this issue step by step. Given the error message you received, it appears that including an
id
within the
assistant
object is not correct. The API is indicating that the
assistant
object should not have an
id
property. To resolve this, we should remove the
id
from the
assistant
object and ensure that we are using the correct parameters as expected by the API. If the
assistantId
is indeed a valid parameter, it might need to be passed differently. Let's try adjusting the code to exclude the
id
from the
assistant
object and see if there's another way to include the
assistantId
. However, without clear documentation, this will be a trial-and-error process. Here's an adjusted snippet without the `id`:
Copy code
python
session = client.calls.create(
    assistant={
        "name": assistant_options.get("name"),
        "firstMessage": assistant_options.get("firstMessage"),
        "transcriber": assistant_options.get("transcriber"),
        "voice": assistant_options.get("voice"),
        "model": assistant_options.get("model")
    }
    # If there's a way to include assistantId outside of the assistant object, it should be added here.
)
If this does not work, we may need to look for alternative ways to specify the
assistantId
. Since the documentation is unclear, I would recommend reaching out to the API provider's technical support for more detailed guidance on how to use the
assistantId
correctly. In the meantime, if you can provide any additional information or context about the API's expected parameters for using an
assistantId
, I will do my best to assist you further.
o
Copy code
{
  "details": "CallsClient.create() got an unexpected keyword argument 'assistantId'",
  "error": "Unexpected error occurred"
}
v
@OlehSavchuk I'm sorry to hear that you're still facing issues. The error message indicates that the
CallsClient.create()
method does not accept an argument named
assistantId
, which means we need to find the correct way to pass the assistant identifier to the method. Since the direct approach and the documentation have not provided a clear solution, I would like to offer further assistance. However, without access to the specific API documentation or the ability to directly query the API's schema, my ability to provide an accurate solution is limited. Given the circumstances, the best course of action would be to contact the API provider's technical support team for detailed guidance on how to correctly use the
assistantId
with the
vapi-server-sdk-python
. They should be able to provide you with the exact parameters and method usage required to start a conversation with an assistant. If you have any other questions or if there's anything else I can assist you with, please let me know.
o
"Given the circumstances, the best course of action would be to contact the API provider's technical support team for detailed guidance on how to correctly use the assistantId with the vapi-server-sdk-python. They should be able to provide you with the exact parameters and method usage required to start a conversation with an assistant." YOU ARE THE TECHNICAL SUPPORT!!!
any updates on that?
v
@OlehSavchuk I apologize for the confusion earlier. Let's try to address the issue with the information we have. The error message you're receiving suggests that the
assistantId
is not being recognized as a valid parameter for the
CallsClient.create()
method. This could mean that the
assistantId
needs to be passed in a different way or that there's a specific method for using an assistant ID that we're not aware of. Since the
assistantId
is not accepted directly, we should consider other ways it might be used. One possibility is that the
assistantId
might need to be part of the payload in a different format, or it might be used in conjunction with other parameters. Here's what you can try: 1. Check if there's a different method or parameter for using
assistantId
. This could be something like
assistant_id
instead of
assistantId
, or it might need to be passed within a different structure. 2. If you have any example requests or responses from the API documentation or from the API provider that show how to start a call with an assistant ID, please refer to those examples. 3. If there's a support forum, community, or other developers who have integrated with the same API, consider reaching out to them for insights. 4. As a last resort, if you're still unable to resolve the issue, please provide me with any additional context or error messages you have, and I'll do my best to assist you further. Again, I apologize for the oversight. Let's work together to resolve this issue. If you can provide any additional information or context, it would be greatly helpful.
o
@User curl -X POST http://127.0.0.1:5000/api/start-call \ -H "Content-Type: application/json" \ -d '{ "assistantOptions": { "assistantId": "", "name": "Vapi’s AI Assistant", "firstMessage": "Hello! I am your assistant. How can I help you today?", "transcriber": { "provider": "deepgram", "model": "nova-2", "language": "en-US" }, "voice": { "provider": "playht", "voiceId": "jennifer" }, "model": { "provider": "openai", "model": "gpt-4", "messages": [ { "role": "system", "content": "You are a professional ." } ] } } }'
@User would you mind to help me with this issue, looks like bot is not able to help me here
b
@OlehSavchuk is your phone number attached to your assistant?
o
@bryant no, I don't understand why I need phone number in this configuration? if I'm using assitant_id I'm confusing why I can use assitant_id directly from frontend using client-sdk without phone number and when I'm using server-sdk to add additional layer of logging and data storing between frontend and Vapi, it's asking for a phone number
@User guys, would you mind to help me with this issue, I'm trying to figure out why the server-sdk isn't working as expected
b
after having a look at the sdk code, it looks like its by default trying to create an outbound call
hence why it's asking for a phone number
o
@bryant so does it mean that the only way to use the Assistant , is only direct conenction from frontend part of the app(React) to the Vapi server?
s
@OlehSavchuk with the web SDK, you can only make web calls, while the server SDKs require a phone number to make phone calls. If you don’t mind sharing the full context of your application and how you plan to use it, we can guide you better on what approach to take and which sdks/tools to use.
3 Views