Collecting and Processing Data using an AI Assistant
When building your AI assistants, you will often want to collect data from your users for later use using output fields and process that data using a flow, for instance to create or update a record in your CRM, write a row to a Google Sheet, etc.
If you don't have any assistants that collect data yet, and you want to follow along with this tutorial, you can install this assistant template, which is a simple data gathering assistant.
There are two methods you can use to use the output data in a flow, and which one you choose depends on how you have deployed your assistant.
1. Create a flow with an "Assistant Event" trigger
2. Use the output from the "Run Assistant" task
Usually you will want to use option 1. An "Assistant Event" flow will work no matter how you deploy your assistant, and also works with the test console in the assistant editor. Option 2 only works when you are launching your assistants inside a Flow. We'll show both methods.
First, let's take a look at a sample assistant that has some output data (you can find the template for this assistant linked above). This assistant is registering prospective event attendees for an event, and asks a number of related questions and then outputs the answers the questions as data.
And here are the output fields:
This assistant simply walks the user through a questionnaire, gathering the required information, and adds the answer to its output as it goes.

That's very nice - but it isn't very useful unless we can do something with the data once it has been collected. For that, we'll need to create a new Flow with an "Assistant Event" trigger.
From the main navigation on the left click "Flows" and then "New" and pick "Blank Flow" as your template. You should then see this screen where you can select how you want the flow to be triggered:

Once you select the Assistant Event trigger, you will need to pick which assistant event should trigger this flow, and for which assistant. Note that if you do not choose a specific assistant,

For the purposes of processing assistant output data, there are two assistant events that you can use:
* Assistant Run Completed - this triggers when the conversation is completed
* Assistant Run Updated - this triggers on each turn of the assistant. In this example, after each question, the flow would be triggered, letting you incrementally update a database record with data it is collected, if you prefer.
Which you choose depends on your use case. Here we'll use "Assistant Run Completed" which will trigger once the registration process is complete.
After you have added a flow and created a trigger, we need to add an action to actually make use of the data we have collected. For this example, we're just going to send a message. In a real scenario, you would use one of our integrations to send an email with the registration information, or add a row to Google Sheets or update a CRM record.

Add a "Send Message" to your flow, and then you can start using the output data from the assistant. Each field you have set up in your assistants "Output Fields" section will appear in the list of available variables (click on the "Flow XO" icon in the top right hand side of the input field you want to use)
Here we created a line for each field, gave it a label and inserted the users response using the appropriate variable.
Now you can save and enable your flow, and it's ready to test. The final flow looks like this:
Now let's give it a try. Go back to your Data Collection assistant, and start a new test session.

It worked! Because our "Assistant Completed" flow just sent a message, the data was output to the chat window. Of course you won't do that in a real assistant, but it's a quick and easy way to test things out.
Using the Output of a Run Assistant Task
Although using an Assistant Event is usually the recommended method of processing assistant output because it works even in the Assistant Test Console, you can also obtain the same output data from a "Run Assistant" task. Using the "Run Assistant" task you can launch an assistant from pre-existing classic flows you may already have in place.
When you run your assistant this way, all of the data output fields are available as output of the Run Assistant action in exactly the same way as they are with the Assistant Event trigger. So once your assistant completes, you can continue to process the output data in the same flow that launched your assistant in the first place.
That's it for our simple data collection assistant. Although simple, this is a very powerful tool for deeply integrating your AI assistants with your workflows and other data systems.
As always, let us know at support@flowxo.com if you have any questions or feedback. We always love to hear from you!
Happy Flowing!