Create a plugin
Learn how to create a new plugin with actions.
1. Create a new GitHub repository
The repository will be used to store the plugin code and configuration.
2. Set up development environment
Open the plugin repository in GitHub Codespaces or clone it on your local machine.
3. Initialize the plugin repository
Use the connery dev init
CLI command to initialize the plugin repository with all the necessary files and configuration.
npx connery@latest dev init
This command will also create a sample action for you to explore and test.
4. Install dependencies
To continue, you must install all the dependencies defined in the ./package.json
file. Run the following command to install the dependencies.
npm install
5. Add a new action to the plugin (optional)
Use the connery dev add-action
CLI command to add a new action to the plugin.
npx connery@latest dev add-action
6. Implement the action (optional)
Open the ./src/actions
directory and find the newly created action file, define the input and output parameters of the action and implement the logic of the action in the handler
function.
Use the sample action as an example and draw inspiration from existing open-source plugins.
7. Start the plugin server
Run the following command to start the plugin server.
npm start
Check the plugin server documentation to learn more.
8. Run the action (optional)
Let's run the plugin's sample action to see how it works. This is helpful for testing the action during the development process.
Use the following command to run the action from the plugin server. You should receive a response with the result of the action execution. The plugin server must be running to run the action.
curl -X 'POST' \
'http://localhost:4201/api/actions/sampleAction/run' \
-H 'accept: application/json' \
-H 'x-api-key: 123456' \
-H 'Content-Type: application/json' \
-d '{
"input": {
"number1": "1",
"number2": "2"
}
}'
9. Commit the files
Run the following command to commit and push all the files to GitHub.
git add . && git commit -m "Init plugin repository" && git push origin main
Make sure you delete all the secrets you might be using during testing before pushing the changes to the repository.
Last updated
Was this helpful?