deep-jade
deep-jade15mo ago

Function for OpenAI Assistants V2

Hi there, I've been using this function in order to use the OpenAI Assistants: https://www.voiceflow.com/function/openai-assistants-api It works very well, however I noticed it only works with V1 Assistants. Is there a function that is able to support calls to V2 Assistants, so that we can utilize GPT-4o? Thanks!
3 Replies
Tico | Voiceflow Assistant
Voiceflow provides a robust platform for creating interactive voice assistants. You can implement functions within Voiceflow that can transform user input, interact with APIs, and control the flow of the conversation. Here's an example of how to make a network request using the Fetch API in Voiceflow:
export default async function main(args) {
const response = await fetch('https://cat-fact.herokuapp.com/facts');
const responseBody = await response.json();

const facts = responseBody.map(fact => fact.text);

return {
next: 'success',
trace: facts.map(text => ({ type: 'text', payload: { message: text } }))
};
}
export default async function main(args) {
const response = await fetch('https://cat-fact.herokuapp.com/facts');
const responseBody = await response.json();

const facts = responseBody.map(fact => fact.text);

return {
next: 'success',
trace: facts.map(text => ({ type: 'text', payload: { message: text } }))
};
}
This function fetches data from an API and processes the response. It then creates traces for each item to include in the assistant's response. Please note that certain JavaScript methods, such as setTimeout, are not supported out-of-the-box due to their dependence on browser or Node.js runtime APIs and not part of the ECMAScript JavaScript language specification itself. For more detailed guidance, you can refer to the Voiceflow Functions Documentation. By following the steps and specifications provided in this guide, you can enhance the capabilities of your Voiceflow assistant.
W. Williams (SFT)
DM me I'll send it to u in the morning
deep-jade
deep-jadeOP15mo ago
thank you sir

Did you find this page helpful?