can workflow api request handle array of outputs?
# support
c
for example, the api endpoint returns a list of items. How can i get the assistant to read out the list of returned items?
v
To get the Vapi assistant to read out a list of items returned by an API endpoint, you can follow these steps: 1. Make a GET Request to the API endpoint to retrieve the list of items. Use the following endpoint:
Copy code
GET https://api.vapi.ai/assistant
Ensure you include the necessary headers, especially the Authorization header with your Bearer token. 2. **Process the Response**: Once you receive the data, you can use the
SayHook
feature to read out the items. This feature allows you to specify the text that the assistant will speak. Here’s a simple example using JavaScript's Fetch API to get the list and read it out:
Copy code
javascript
   async function getAssistants() {
     const response = await fetch('https://api.vapi.ai/assistant', {
       method: 'GET',
       headers: {
         'Content-Type': 'application/json',
         Authorization: `Bearer ${token}`,
       },
     });

     const data = await response.json();
     const items = data.items; // Assuming the response has an 'items' array

     // Use SayHook to read out the items
     items.forEach(item => {
       // Here you would implement the SayHook to read each item
       console.log(item); // Replace this with the SayHook implementation
     });
   }

   getAssistants().catch(console.error);
3. **Implement SayHook**: You can intercept the text that your assistant speaks by using the
exact
or
prompt
properties in the SayHook to customize the output. Make sure to handle any errors and ensure your API requests are authenticated properly. If you have any more questions or need further assistance, feel free to ask! 😊 Sources: - [API Reference for Listing Assistants](https://docs.vapi.ai/api-reference/assistants/list) - [JWT Authentication Documentation](https://docs.vapi.ai/customization/jwt-authentication) - [Changelog for SayHook](https://docs.vapi.ai/changelog)
c
to clarify, i'm using the workflow feature in VAPI, which has an 'API Request' step. I'm calling an external endpoint, which returns a list of items. What would the next step be to get the assistant to read out the list of items?
p
Hey using insert variables in next block you can use the output of API request.