Starter kits
We provide starter kits to help you get started with building bots quickly:Language | Template |
---|---|
TypeScript | bot-typescript |
Python | bot-python |
Receiving events
Your bot needs to expose an HTTP endpoint (for example,/webhook
) to receive events from Automa. For security, you should also verify the webhook signature to ensure that the request is coming from Automa. You can read more about the available webhook events and how they are structured in the Webhooks reference guide.
The starter kits already handle this, and the endpoint they provide is /automa
. They also require the AUTOMA_WEBHOOK_SECRET
environment variable to verify the webhook signature.
Handling tasks
When a task is created, your bot will receive atask.created
event. You can then download the code from Automa and begin making changes. Once you are done, you can submit the changes back to Automa, which will create a pull request in the repository.
The starter kits contain the logic to do this using the code.download
and code.propose
methods from the Bot SDKs.
Changing code
After downloading the code, you can make changes to it based on the task requirements. The starter kits include an emptyupdate
function that you can implement to modify the code. This function is called from the webhook handler with the downloaded code’s location and the task data.
Testing
The starter kits include a test suite for the webhook handler that you can run to ensure your bot works correctly with Automa. You can also write your own tests to cover specific functionality for theupdate
function or other parts of your bot.
If you want to test your bot with real tasks, follow these steps:
1
Run the bot locally
Start the bot locally. This will start the HTTP server that listens for
incoming requests.
2
Expose the bot with a tunneling service
Use a tunneling service like ngrok to expose your
local bot to the internet. This will provide you with a public URL that
Automa can use to send webhook events.
3
Update the webhook URL
Update the webhook URL for your bot in Automa to point to the public URL
provided by the tunneling service.
4
Create tasks
Use either the Automa UI or connected integrations to create a task for the
bot. Automa will send webhook events to your bot’s endpoint, allowing you to
test its functionality.