-
Notifications
You must be signed in to change notification settings - Fork 26
2. The Instant Answers modules
There are different types of Instant Answers modules. Some of them fetch their data from third party APIs, others from local or external data sets. Some IA don't even require any data set and can just be tools that do simple operations.
There are two types of IAs:
- "Server-side IAs", which require local or no data sets at all.
- "API friendly IAs", which allow to call an external service (API). However, we reserve the right to blacklist services that don't comply with our rules.
Each instance of an Instant Answer module runs as a service on Qwant's search engine. Depending on the type of Instant Answer you're developing, there might be some specifities you need to know.
The result of an IA is calculated locally, and the data can come from local data sets or an API. The workflow is pretty simple:
Behind the scene, the code running an Instant Answer is pretty simple and relies on a mix of Node.js and doT.js for template files.
Let's break down one of our existing Instant Answers to see what kind of files we are working with!
The Encryption Instant Answers gives a user a hash for a given string and encryption method. For example:
Here are the main files for the Encryption IA. You can see each file on our github repository, by clicking on it.
File | Purpose | Importance |
---|---|---|
encryption.js (src/modules/encryption/encryption.js) |
This file is the main JS file of the module and initializes it with several options (trigger word, trigger type, flags...) It also calculates the answer to the user's query. |
MANDATORY |
encryption.dot (src/modules/encryption/public/encryption.dot) |
This is the template file, where is defined the HTML that will be displayed inside the ribbon on the results page. | MANDATORY |
Language files: br.po, co.po, de.po, en.po, eu.po, fr.po (src/modules/encryption/lang_src/*.po) |
PO files are catalogs or dictionnaries for gettext messages. We need them to translate some of the things our IA might display so that every Qwant user can take full advantage of our IAs. | MANDATORY |
encryption.scss (src/modules/encryption/public/css/encryption.scss) |
If we want to customize the layout defined in the template file, we can use this SCSS file. Uses SASS. | OPTIONAL |
Some Instant Answers will also have other files. For example, if you need a JavaScript file to interact with your templated HTML, you can specify it in your main js file (here, encryption/encryption.js). Take a look at the Timer and Unit Converter Instant Answers to have a better idea of what you can do.
These files have specific names that are derived from your IA's name. These names must not be changed. They are the link between your IA and our core code, so the IA would not work properly without this naming convention.
Let's now see how you can start contributing!