How to set up the Web Search AI Agent tool using Google Gemini
New article articles in ServiceNow Community
·
Apr 03, 2025
·
article
### **How to set up the Web Search AI Agent tool using Google Gemini**
Web Search is a powerful tool available for ServiceNow AI Agents, new in the Yokohama release. It can provide information beyond what’s available in your ServiceNow instance to power your AI Agent knowledge and workflows. There are two ways to perform a Web Search - “Search and scrape” or “AI Answers”. By using search and scrape, you are calling the search engine to return a list of related web links and a web scraping service to scrape those websites. The two options are Bing search or Google search. Then, it passes the scraped data to Now LLM to generate a response. By using AI answers, you are calling an LLM to generate an answer. The two options are Gemini or Perplexity. Gemini uses the Pro 1.5 model. In the below steps, we will mainly be using Google Cloud tools for setting up and using Web Search with AI Agents.
#### Using Search and Scrape with Google Search and ScrapingBee
1. In AI Agent Studio, create an AI Agent. In the description, role, and instructions, prompt to use Google Search. Example:
2\. Add a tool - “Web Search”.
3\. The default provider is Bing Search. Google Search is the other OOB provider.
4\. To change the default provider to Google, click the “open window” button next to the Provider name in the Tools modal. In the OneExtend Definition Configs table (sys\_one\_extend\_definition\_config), switch the True/False “Default” field for the Provider you wish to use, in our case Google Search.
5\. You’ll need to save and exit the tool and agent back in AI Agent Studio for “Google Search” to appear as the Provider.
Navigate to and create a “programmable search engine” and enable a custom search API key. You will need a Google Cloud account. **Note:** You may need to provide billing details, but you get 100 free searches per month. New accounts may also get free credits.
6\. Create your new search engine. See the configuration in the screenshot, such as turning off Image Search since AI Agents only accepts text today.
7\. Back in Google’s documentation, click on “Get a Key”. Select your Google Cloud project to attribute the key.
8\. Copy your API Key (in a secure manner!) The API key should start with “_AI...._”
9\. You may also need to enable the Custom Search API in your Google Cloud console (search for “Custom Search API” in the top toolbar.) The “Enable” button will become “Manage” once you do so.
Return to the ServiceNow instance and navigate to the Connections & Credential Aliases table.
10\. Open the “Google Search API” record.
11\. In the “Connections” related list, click the “Google API key” Credential records. Paste your client secret into the API key field.
Now we need to get a web scraping service. Go to ScrapingBee to sign up for an API key:
12\. In your ScrapingBee dashboard, copy your API key (in a secure manner!). **Note:** You will initially have a limited trial version.
Return to the ServiceNow instance and navigate to the Connections & Credential Aliases table.
13\. Open the “Scraping Bee api” record.
14\. In the “Connections” related list, click the “Scraping Bee Api key” Credential records. Paste your client secret into the API key field.
15\. Modify the **Now LLM** Connections & Credentials Aliases record and field to uncheck the “Is Internal” flag. If this is read-only for you, contact Support to resolve this, or refer to the Troubleshooting section for a background script to update.
Now we’re ready to navigate back to AI Agents Studio to test Web Search.
16\. Open the Web Search tool and set “Output Transformation strategy” to something other than “None”. Otherwise, you’ll get technical jargon.
17\. In the testing tab, select the AI Agent with the Search tool and type in a query. **Note:** The query example below is overly specific. Web Search may not provide relevant search results with vague queries so it’s always good to test.
Results:
Possible errors/troubleshooting:
* API key error: Check to make sure your search API key and ScrapingBee API keys are active and accurate.
* Now LLM error: This could be due to the search results returning data that Now LLM can’t process, like an image.
* 500 error: Sometimes, the website used in web search itself will return a 500 error. You can see this in the ScrapingBee logs.
If you are unable to modify the “Is Internal” field in the Now LLM Alias record: Log a Support Case and ask Support to manually change the flag in maintenance mode.
### Web Search using AI Answers, with Gemini LLM
1. Create an AI Agent with the instructions and Web Search tool similar to the Search and Scrape steps. **Note**: In your AI Agent instructions, state: **Use as search\_type input “ai\_answers”.**
2\. In your Web Search tool, choose your Output Transformation Strategy to something other than ‘None’ to avoid technical jargon. During testing, it’s found that ‘Verbose’ can generate overly long answers.
3\. In the OneExtend Definition Configs table (sys\_one\_extend\_definition\_config), switch the True/False “Default” field for the Provider you wish to use, in this case "Gemini AI answer”, under the Capability: “AI Search answers”.
Now let’s get a Gemini LLM key from Google Cloud.
4\. Create a Google Cloud Platform account and Project. Go to [https://aistudio.google.com](https://aistudio.google.com/) and click “Get API key”/ “Create API key”. An API key will be generated for your project. Copy the API key (in a secure manner!) Your key should start with “_AI...”_
5\. You can also navigate to the Google Cloud Platform console to review the “Generative Language API”. Note the Service name (generativelanguage.googleapis.com) will match the Host URL of the Connection record in the next step.
6\. Return to ServiceNow instance and navigate to the Connections & Credentials Alias page. Select the “Google gemini API” record. Click into the Credential record in the related list.
7\. Paste the API key into the “Google gemini API key” Credentials record.
8\. Return to your AI Agent and test it.
### Quick Pros/Cons between Search & Scrape, and AI Answers
* Search & Scrape may provide uneven quality answers, depending on the websites found and the information scraped within it. AI Answers provide more consistent formatted answers.
* Search & Scrape requires a scraping tool, which can be expensive. E.g., ScrapingBee is $49/mo at time of writing. AI answers from LLMs also is not free but are very cheap.
* AI answers search in LLMs that have knowledge cutoffs. E.g., Gemini 1.5 Pro LLM has a cutoff of January 2025\. Search & Scrape do not have knowledge cutoffs.
https://www.servicenow.com/community/now-assist-articles/how-to-set-up-the-web-search-ai-agent-tool-using-google-gemini/ta-p/3227494
Victor Chen