Skip to content

search()

Return custom results when a user searches for a Flow script through Otto.

Updated View as Markdown
For humans
Flow functionFlow Pro scriptingBase functions

This article covers the following platforms

search runs when the user types a search query for this script in the Otto search bar.

let result_1 = null; // Keep track of those if you want to re-use them on query updates
let result_2 = null;
let result_3 = null;
const prefixes = ['hello'];

search(prefixes, (query, callback) => {

	var result_1 =  {
		uid: 'result_1_unique_id',
		label: 'World',
		subtext: 'This is a subtext for query: ' + query,
		is_note: true,
		execute: () => {
			// Do something when clicked
			return false; // Omit or false to close Otto, true to keep it open;
		}
	};

	var result_2 =  {
		uid: 'result_2_unique_id',
		label: 'World',
		image: 'https://github.com/parallel42/flow-documentation/raw/main/flow_logo.svg',
		subtext: 'This is a subtext for query: ' + query,
		execute: () => {
			// Do something when clicked
			return false; // Omit or false to close Otto, true to keep it open;
		}
	};

	var result_3 =  {
		uid: 'result_3_unique_id',
		label: 'Long World',
		subtext: '<p>This is a long text... it can also be wrapped in html</p>',
		execute: null,
		image: 'https://en.wikipedia.org/wiki/Google_logo#/media/File:Google_2015_logo.svg',
		is_text: true
	};

	callback([result_1, result_2, result_3]); // Callback can be called multiple times if results need to be renerated asynchronously but must always include the list of all results.
});
  • prefixes: Array of prefixes that trigger the search (like the default metar and tod searches).
  • query: The entire query as a string (the content of the Otto search bar).
  • callback: Call this to return the list of results in the format shown in the example.
Navigation

Type to search…

↑↓ navigate↵ selectEsc close