How to get AI Assist to create leads via Google Forms

The instructions below are for desktops and laptops only.

Get AI Assist to generate leads directly from live chat conversations. By connecting your AI agent to a Google Form using Google Apps Script and a simple OpenAPI specification, the customer details collected during chats are automatically sent to your Google account—making tracking and follow-up faster and easier.

Before you start

Here’s what you’ll need:

  • An active paid AI Assist plan (Growth, Business, or Enterprise)

  • A Google account with access to Google Forms and Apps Script

  • A little coding knowledge (Google Apps Script and OpenAPI). If you’re not comfortable, you can adapt the public examples provided in this guide or ask a developer for help. For more information, visit our developer portal.


Examples of this integration are available in our public GitHub repository for your reference.

Prepare your Google Form

1. Go to Google Forms.

2. Create a new form and add fields for the information you want to collect (e.g., Name, Email, Phone Number, Message). Keep field names clear and consistent — you’ll reference these names in both your Apps Script and your OpenAPI specification. 

Add an Apps Script web endpoint

To allow AI Assist to send data to your Google Form, you’ll need to set up an Apps Script endpoint.


Here’s how:


1. In the Google Form editor, click the three-dot menu and select Apps Script.

2. In the Apps Script console, enter a script in Code.gs to describe the methods to query your sheet. You may copy the script in this example.

3. After adding the script, deploy the script as a Web App. Click Deploy > New deployment.

Click the gear icon next to Select type and choose Web app.

4. Enter the Description.

5. Set Execute as to Me. This gives your script access to your sheet.


6. Set Who has access to Anyone. This allows AI Assist to query your sheet using your script.


7. Click Deploy.


8. Copy and save the Web App URL — you’ll need it for the OpenAPI specification.


Note: Each deployment creates a new URL, so be sure to update it if you redeploy.

Create an OpenAPI specification

You’ll need an OpenAPI specification, like a YAML file, that defines the interaction between AI Assist and your Google Form.


You may copy the specs in this example. Ensure to:

  • Replace the servers.urls value with the Web App URL copied from the Apps Script above.

  • Remove /exec from the end of the URL.

  • Modify relevant parameters to fit your needs. For more information on customizing the specs, click here.


You can edit and test your API specifications using an online editor like Swagger.

Copy and save your raw file’s URL. You’ll need it for the next section.

The integration name
The title in your specifications will appear as the integration name on your tawk.to dashboard.

For example:

This is how it’ll appear on your dashboard:

If you have multiple API integrations, give each one a descriptive name so it’s easy to find.

The operation name

AI Assist is designed to understand the context of the inquiry and use the relevant operationId in your API schema. In this example, the operation name is submitForm.
Now, let’s complete this integration on the tawk.to dashboard.

Add the integration in tawk.to

Note: You’ll need a paid AI Assist plan to perform this integration.

1. Log in to your tawk.to account.

2. Select the correct property.

3. Go to Add-ons.

4. Under AI Assist, click Settings.

5. Select your AI agent.


6. Click Integration/API.

7. Click Add tool under API.

8. Enter your OpenAPI specification file’s URL in Schema File URL.

9. Leave API Base URL blank and set Authentication method to No Auth


10. Click Save.

Update the Base Prompt

Update the Base Prompt for your AI agent to ensure it knows when to send details to the form.

1. Go to the Base Prompt.

2. Enter instructions to train AI Assist to

- capture customers’ details via the form, and
- submit the form using an API call

For example:

- If the customer needs more information, say “We’ll be happy to send you more details” and capture the customer’s details in the Google Form. Ask the customer for their details one by one and don’t proceed to the next question until the current one is answered. Then, use the submit form API call.

You can also instruct AI Assist’s response after submitting the form, for example:


- After receiving a response from the submit form API call, say the following depending if it was successful or not:If the form submission was successful, say: “Thank you. Our representative will contact you shortly.What else would you like to do?[option] Go back to the main menu[option] More product info”If the submit form submission failed, say: “I’m sorry, that didn’t work. Please reach out to info@example.com”

3. Click Save.

Test and refine

  1. Start a test chat with your AI agent.

  2. Provide sample details (e.g., name, email, phone).

  3. Check your Google Form to confirm that the data has been captured correctly.

  4. If something doesn’t work, double-check your Google Apps Script permissions, Web App deployment, and OpenAPI specification.

Additional considerations

  • Make sure your Google Apps Script deployment is set to Anyone; otherwise, AI Assist won’t be able to send the data.

  • You can add more fields to your form, but you’ll need to update both the Apps Script and the OpenAPI specification to match.

  • Only collect the data you need, and make sure it’s stored securely. Follow applicable data protection regulations (such as GDPR) and avoid sending unnecessary personal information.


  • Google Apps Script has execution limits. Test your setup under expected traffic and build in retries or backoff strategies to reduce the risk of failed submissions.


  • Each new script deployment generates a new Web App URL. If you update your script or OpenAPI specification, be sure to update the hosted file and re-save the tool in your tawk.to dashboard.


For more information about AI Assist, data sources, and integrations, see these guides:

Getting started with AI Assist

Understanding the Base Prompt

How AI Assist uses your data securely

Deploying multiple AI Agents across support channels

How to set up a custom API integration with AI Assist


If you have feedback about this article, or if you need more help:

Was this article helpful?

9 out of 14 liked this article

Still need help? Message Us