With the HTTP API, you can request actions over the HTTP protocol and also provide queries to Leon from external services.
That means you can easily communicate with Leon from any third-party such as Discord, Signal, Telegram, Messenger and so on...
Example of scenario:
- You send a command on Discord. It could be "!query hello".
- Your Discord bot catches it and forward "hello" to your Leon server.
- Leon executes the greeting module and returns the response.
- You handle the response and your Discord bot displays it on Discord.
Leon exposes two types of HTTP endpoints: the query endpoint and actions endpoint.
By default, Leon is exposed over HTTP. You can disable it from the
#HTTP API Key
To request Leon over HTTP, you need to provide the HTTP API key. This key can be found in the
.env file with the environment variable
#Generate a New Key
The HTTP API key is automatically generated during the setup of Leon. If you need to generate a new key, please run the following command:
#The Query Endpoint
Via this endpoint, Leon handles the string you send (query) and then executes the targeted module based on his understanding.
By default, every module action is exposed over HTTP. Leon automatically translates actions into HTTP endpoints based on the configuration.
You can find the generated endpoints in the
Let's try an example with the "run" action of the "greeting" module.
Now let's try another example with an action module that requires parameters/entities to work.
Some actions require specific inputs (entities) and developers of these actions should add support to fully expose them over HTTP.
To know what parameters to put in the body data, go to the
These options can be configured at the action level in the
|HTTP method of the action.|
|Execution time before timeout (in ms).|
|Disable a specific action.|
|Entities that can be passed as parameters in the body data|
- For entities, you can take example on
- For a full list of the entities format, please check here.