Search Flows
A Search Flow is responsible for taking a natural language query and returning data from whichever platform it needs to.
Many Flows will be very simple like the one below, which performs an Elastic Search query on a movies database.
However, you can add all sorts of custom logic to address more complex scenarios.
Receiver Data object
Search Flows using the AI Search Prompt Block expect to receive an input object in the Receiver.
This has the following format
{
query: 'the natural language query',
isAIQuery: true, // always true
offset: 0, // optional: but required for pagination
limit: 10, // optional: but required for pagination
count: false, // optional: true returns a count
cachedQuery: {}, // optional See below.
fetchIds: false, // optional: set to true if you want the query to return a list of matched IDs
restrictToIds: [], // optional: a list of IDs that the search should restrict the search to
responseType: '', //optional. See below
callingUserId: '', // optional: see below
}
The following optional parameters are available.
cachedQuery
- the search Block (Elastic, SQL etc) returns this object after the first query call and this data is returned from the Flow. When using pagination after the first page, you should set this object with the returnedcachedQuery
object.responseType
- the current options are '', 'chatterbox'. All responses are returned in a standardised data format. 'chatterbox' is also a standardised format, just tailored for ChatterBox. You can use this format in your own front end if its suits your requirements.callingUserId
- this is reserved for Slack usage. It is the Slack user id for targeting response data to the user making the request.
AI Prompt Block
This Block is responsible for turning the natual language query into a platform specific one. Its main features are
- Uses a fully customizable LLM prompt to do the query translation.
- It has templates for standard platforms so you only need to add use-case specific customizations. Or you can rewrite the entire prompt should you wish to.
Platform specific Block
the AI Prompt Block outputs a query in the right format to the search Block. Common examples are
- SQL (includes data warehouses like SnowFlake, BigQuery etc)
- Elastic Search
- Hubspot, SalesForce (etc.)
- Any REST API
- We can also build custom search blocks for any platform that offers an API or a well defined query language of some sort.
Terminator
It is important that the Send data in response box is checked, so the calling flow receives the search results.
Custom Logic
Many search Flows contain just the AI Prompt Block and the platform specific search Block. However, any additional logic can be added into a Flow.
The second image at the top of this page can be called by both ChatterBox and Slack to perform a HubSpot search.
- You can see the AI Prompt and Hubspot Search Blocks on the top row.
- It then simply returns data to ChatterBox if the query can from ChatterBox...
- or passes it to one of the two Slack Blocks Formatter Block if the request came from Slack.
Non AI Search
In some cases, you may require a query that does performs a high targeted search. The one below, for example, is called when a Hubspot company is passed in and the associated deals should be returned, to Slack in this case.
Testing Flows
You can test your search Flows directly from the Ziggy UI. You can provide test data in the Receiver Block so you don't have to call it from whichever front end you are using.
Ziggy provides excellent debugging features that let you step through the Flow, one block and a time.
You can then inspect the data flowing between Blocks to diagnose issues. For example, you might want to see exactly what data is being output from the AI Search Prompt Block. This might inform what prompt changes you need to make in that Block to pass an better query to the search block itself.
Prompt Engineering
You have full control over the prompt itself within the AI Search Prompt Block. This includes the ability to test natural queries directly from the Block itself.