There is no API for workflows?
# support
l
Our application generates a custom assistant, via an initial call to our api on assistant-request, and then sends back a generated (curated) xml for creating an assistant dynamically with client details embedded. How would I fetch and attach workflows to the dynamic created assistants? One can do this in the dashboard, but that will mean dynamic created assistants using workflows is not possible.
v
To fetch and attach workflows to dynamically created assistants in the Vapi platform, you can follow these steps: ### Step 1: Create the Assistant - Use your API to create a new assistant by sending a request to the
assistant-request
endpoint. Ensure that the client details are embedded in the XML you generate. ### Step 2: Switch Provider to "Vapi" - In the assistant's configuration, set the provider to "Vapi" to ensure that the Vapi model handles the interactions. ### Step 3: Fetch Workflows - To fetch existing workflows, you can use the Vapi API to retrieve a list of workflows. This typically involves making a GET request to the appropriate endpoint that lists workflows. ### Step 4: Attach Workflows - Once you have the workflow ID from the fetched workflows, you can attach it to your dynamically created assistant. This is usually done by sending a POST request to the assistant's endpoint with the workflow ID included in the request body. ### Example Code Snippet Here’s a simplified example of how you might implement this in code:
Copy code
javascript
// Fetch workflows
const workflows = await vapiSDK.getWorkflows({ apiKey: apiKey });

// Attach a workflow to the assistant
await vapiSDK.attachWorkflowToAssistant({
  apiKey: apiKey,
  assistantId: createdAssistantId,
  workflowId: workflows[0].id // Assuming you want to attach the first workflow
});
### Important Considerations - Ensure that the endpoint URLs you are using for API calls are correct and refer to the latest Vapi documentation. - Workflows need to be fully configured before they can be attached to an assistant. This approach allows you to dynamically create assistants and attach workflows programmatically, enabling a more flexible integration without relying solely on the dashboard. Sources: - [Creating an Assistant](https://docs.vapi.ai/workflows#step-1-create-an-assistant) - [Switch Provider to Vapi](https://docs.vapi.ai/workflows#step-2-switch-provider-to-vapi)
l
@Vapi Support Bot The workflow API is not documented. can you point me to docs that describe the workflows api endpoints.
k
Hi Lucas, You're right while the Workflow API exists in Vapi, it's not fully documented in our public documentation yet. We will let you know once they are made public.
10 Views