Invoking a Yandex Cloud Functions function
You can integrate a form with a Yandex Cloud Functions function. For example, you can collect user data and transfer it to a website or database to register customers using the form.
Alert
You can integrate a form with Cloud Functions functions only using forms for business. To do this, make sure a form has a Yandex Cloud organization enabled with a cloud configured.
Step 1. Create a service account
- Go to the Yandex Cloud management console
. - In the left-hand panel, select the folder to create a function in.
- In the top-right corner, click
→ Create service account. - In the service account creation window, fill in the following fields:
- Name; it may only contain lowercase Latin letters, numbers, and hyphens.
- Description; it may contain any characters.
- In the Roles in folder field, add the
functions.functionInvoker
role.
- Click Create.
If no billing account is linked to your Yandex Cloud account, a window for creating a billing account will open. Fill in its fields to create an account. For more information, see Creating a billing account.
Step 2. Create a service account key
- In the left-hand panel of the management console
, select the folder where the appropriate service account is located. - Go to the Service accounts tab.
- Select the account you need.
- In the top panel on the account page, click Create new key → Create API key.
- Provide a brief description for the key.
- Click Create.
- This will open a window with the key ID and the secret key. Store them in a secure place. You will not be able to access them after you close the window.
Step 3. Enable cloud function invocation
- In Yandex Forms, open the form to set up the cloud function integration for.
- Go to the Settings tab and select Additional in the left panel.
- Under Cloud function key, fill in the Key ID and Secret key fields. Paste the values you copied when creating the service account key there.
- Click Save.
Step 4. Create a cloud function
- Go back to the Yandex Cloud management console
. - In the left-hand panel, click
and select Cloud Functions. - In the top-right corner, click Create function.
- On the function creation page, fill in the following fields:
- Name; it may only contain lowercase Latin letters, numbers, and hyphens.
- Description; it may contain any characters.
- Select the programming language that your function will be written in.
- Select a tab with the function source:
- Code editor to write the function code directly in it.
- Object Storage to select a bucket and object with the appropriate function.
- ZIP archive to attach a
.zip
file with the appropriate function.
- You can optionally set up the function parameters and logging. All parameters required for creating a function are preset.
- Click Save changes.
- On the function page, copy the value from the ID field.
To learn more about creating functions, see the documentation for cloud functions.
Step 5. Set up integration
- Go back to the form and click the Integrations tab.
- Select a group of actions to set up issue creation in and click Cloud Functions at the bottom of the group.
- In the Function code field, paste the function ID that you copied in the previous step.
- Under Parameters, you can optionally select additional parameters to be transferred to the function.
- Click Save.
Responses to the form will be delivered in JSON format. See its structure below:
{
"id":<form_response_ID>,
"uid":"<user_ID>",
"data":{
"<question_ID_with_its_type_specified>":{
"value":<response_to_question>,
"question":{
"id":<question_ID>,
"slug":"<question_ID_with_its_type_specified>",
"options":{
<question_parameters>
},
"answer_type":{
"id":<question_type_ID>,"slug":"<question_type>"
}
}
}
},
"survey":{
"id":"<form_ID>"
},
"created":"<response_date>",
"cloud_uid":"<user_ID>"
}
You can view the sent request and the function execution results on the completed integrations page.