> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: invoke(options: Options, context: Context) # Method package: wixAutomations # Method menu location: wixAutomations --> AutomationsActions --> invoke # Method Link: https://dev.wix.com/docs/velo/events-service-plugins/automations/service-plugins/automations-actions/invoke.md # Method Description: Runs your custom action when an automation is triggered. Wix calls this function when an automation is triggered, for example by a form submission or a completed order. Therefore, write any code for your action in `invoke()`. Use the [Velo APIs](https://www.wix.com/velo/reference/api-overview) to create your action in the same way as you use them in your site's page code. For example, let's say you want to save a site visitor's contact data to a collection when they submit a form. In this case, Wix calls `invoke()` when the form is submitted. Write the code to save the contact data, using the relevant [wix-data](https://www.wix.com/velo/reference/wix-data) methods, in the `invoke()` function. `invoke()` accepts the trigger payload as a parameter. This payload changes depending on what your trigger is. You can access the payload fields and use them in your action code. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Save data of a customer who purchased a plan ```javascript import wixData from 'wix-data'; export const invoke = async ({payload}) => { const toInsert = { "plan_id": payload.plan_id, "plan_name" : payload.plan_title, "name": payload.contact.name , "email": payload.contact.email, "phone": payload.contact.phone }; // Insert the customer data into our site collection // of contact data for plan purchasers try { const results = await wixData.insert('CustomerData', toInsert); console.log('Data inserted successfully:', results._id); // Log the ID of the inserted item } catch (error) { console.error('Error inserting data:', error); // Handle the error } return {}; // The function must return an empty object } ``` ---