Build Tools to Connect Your CRM to AI

Your account managers spend the first ten minutes of every client call digging through the CRM. They need the contact's name and role, the deal history, and what happened in the last few weeks. The CRM has an API, but nobody outside of engineering knows how to use it. The data is there -- it is just locked behind a UI that takes too many clicks.

This playbook walks you through building five tools that let anyone on your team pull CRM data from their AI client. You will build a contact lookup, a deal search, an activity feed, and an account summary tool that chains multiple API calls together. By the end, your account managers can ask "Give me a prep sheet for my call with Acme Corp" and get everything they need in one response.

Most of this workflow happens from your AI client (Claude Desktop, ChatGPT, Cursor) through the MCP connection to Assist. The one exception is credential configuration: the CRM API key should be entered directly in the Assist UI under the Permissions tab of each tool so it never passes through chat.

What you need before you start

  • An Assist workspace with an MCP connection configured in your AI client
  • Your CRM's API base URL (for example, https://api.yourcrm.com/v3)
  • An API key for the CRM
  • A few sample account names, contact emails, or deal IDs you can use for testing

Phase 1: Map the CRM API

Start by telling the AI what you know about your CRM's API. You do not need to know everything -- just enough to get started.

"I need to build tools that query our CRM. The API is at https://api.yourcrm.com/v3. It uses an API key passed in an X-API-Key header. The main resources are /contacts, /deals, /activities, and /accounts. Contacts belong to accounts. Deals belong to accounts and have stages. Activities are linked to contacts or deals."

If you have API documentation, share it.

"Here's the relevant parts of the CRM API docs: contacts can be searched by email, name, or account_id. Deals can be filtered by account_id, stage, and close_date range. Activities can be filtered by contact_id, deal_id, type, and date range. Activity types include 'email', 'call', 'meeting', and 'note'."

The AI now has a mental model of your CRM's data structure. It will use this to write tools that make the right API calls and return useful data.

Phase 2: Build the contact lookup tool

Start with contact lookup. Account managers need to find a contact quickly by name or email.

"Create a tool called 'crm_lookup_contact' that searches for a contact. It should accept a query string that could be a name, email, or phone number. Call GET /contacts/search?q={query} on the CRM API. Use the X-API-Key header with a value from an environment variable called CRM_API_KEY. Return the contact's full name, email, phone, title, company name, and account ID."

The AI creates the tool. Test it with a contact you know exists.

"Test crm_lookup_contact with query 'jane.doe@acmecorp.com'."

If the test fails with a network error, open the tool in the Assist UI, click the Permissions tab, and add api.yourcrm.com under Network Access.

If the test fails with a 401 or 403, the API key is not configured. In the same Permissions tab, under Environment Variables, add CRM_API_KEY as a custom variable and paste the key into the masked value input. Do not paste the API key into chat -- the masked field in the Permissions tab keeps the value out of the LLM context and chat history. See Managing Permissions for the full UI flow.

Review the output once the test passes. You might notice the API returns more data than you need, or the format needs work.

"That works but the response includes internal IDs and metadata we don't need. Clean it up to only return full_name, email, phone, title, company_name, and account_id. Also, the API returns an array even for single results -- if there's exactly one match, return it as a single object instead of an array."

"Test again with 'jane doe' to make sure name search works too."

Iterate until the output is exactly what an account manager would want to see before a call.

Phase 3: Build the deal search tool

Account managers need to see the deal history for an account. What deals are open, what closed recently, and what's in the pipeline.

"Create a tool called 'crm_search_deals' that searches deals. It should accept: account_id (optional), stage (optional, one of 'prospecting', 'qualification', 'proposal', 'negotiation', 'closed_won', 'closed_lost'), min_value (optional, number), max_value (optional, number), and close_date_from and close_date_to (optional, ISO 8601 dates). Call GET /deals with these as query parameters. Return deal name, stage, value, close date, owner name, and probability."

Test it.

"Test crm_search_deals with account_id for Acme Corp. I think the account_id is 'acc_12345'."

Review and refine.

"The deal values are coming back in cents. Convert them to dollars with two decimal places. Also, sort by close_date descending so the most recent deals show first."

"Test with stage 'negotiation' to see all deals currently in negotiation across all accounts."

Make sure the tool handles empty results gracefully.

"Test with an account_id that has no deals to make sure the response is clear when there are no results."

"Good, but instead of returning an empty array, return an object with an empty deals array and a message like 'No deals found matching your criteria.' That's more helpful."

Phase 4: Build the activity feed tool

Before a call, account managers want to know what happened recently. What emails were exchanged, what meetings happened, what notes were left.

"Create a tool called 'crm_get_activity_feed' that returns recent activities. It should accept: contact_id (optional), account_id (optional), deal_id (optional), activity_type (optional, one of 'email', 'call', 'meeting', 'note'), and days_back (optional, defaults to 30). Call GET /activities with the appropriate filters. Return the activity type, date, subject or title, a short summary if available, and who created it."

Test with a contact.

"Test crm_get_activity_feed with the contact_id for Jane Doe."

The activity feed will probably have a lot of data. Refine it.

"There are too many results. Limit to the 20 most recent activities by default. Also, the email activities include the full email body which is too long. Truncate the summary to the first 200 characters."

"The date format is wrong. Use ISO 8601 dates."

"Test with activity_type 'meeting' and days_back 7 to see just the meetings from the last week."

Phase 5: Build the account summary tool

This is the most powerful tool. It pulls together data from multiple endpoints to give a complete picture of an account. This is the "call prep" tool.

"Create a tool called 'crm_account_summary' that takes an account_id or account_name. If given a name, first search the /accounts endpoint to find the account_id. Then pull together: the account details (name, industry, size, website), the primary contacts (up to 5), the active deals (any deal not in closed_won or closed_lost), the most recent 10 activities, and a total revenue figure from closed_won deals. Return all of this in a structured object."

This tool makes multiple API calls. The AI will write code that fetches data from several endpoints and combines it into a single response.

"Test crm_account_summary with account_name 'Acme Corp'."

This is a complex tool so expect some iteration.

"The contacts section is good. But the deals section should group deals by stage so I can see what's in each stage at a glance. And the activities should show the most recent ones, not the oldest."

"Add a 'relationship_health' field that says 'active' if there have been any activities in the last 14 days, 'cooling' if the last activity was 14-30 days ago, and 'inactive' if there have been no activities in the last 30 days."

"The total revenue field is showing null. I think the closed_won deals endpoint returns the value in a field called 'amount', not 'value'. Can you check and fix?"

Test with a few different accounts to make sure it handles edge cases.

"Test with an account that has no deals to make sure it doesn't break."

"Test with an account name that has multiple matches. What happens?"

"Good, it returns the first match. Instead, return the list of matching accounts and ask the user to specify an account_id."

Phase 6: Configure the API key properly

So far you have been setting the API key directly on each tool. For production, you want a cleaner setup where the API key is configured once and shared across all tools.

"For each of the CRM tools, confirm that the code references CRM_API_KEY as an environment variable."

The AI can check the code, but the actual key values only live in the Permissions tab of each tool.

If your workspace has a CRM connection configured, prefer linking to it instead of entering the raw value. For each CRM tool, open the Permissions tab, and in the Environment Variables section switch to the From Connection tab and link CRM_API_KEY to the "CRM Production" connection. This way, when the API key rotates in that connection, all tools pick up the new value automatically.

Phase 7: Test the complete workflow

Now test the way your account managers will actually use these tools. Ask natural questions and see if the AI picks the right tools.

"I have a call with Jane Doe at Acme Corp in 30 minutes. What do I need to know?"

The AI should use crm_lookup_contact to find Jane, crm_account_summary to get the full picture, and crm_get_activity_feed to show recent interactions. This is the experience you are building for your team.

"What deals do we have in negotiation right now across all accounts?"

The AI should use crm_search_deals with stage 'negotiation'.

"Show me all the meetings we had with Acme Corp last week."

The AI should use crm_get_activity_feed with account_id and activity_type 'meeting' and days_back 7.

If any of these do not work the way you expect, iterate on the tool descriptions. The description is what the AI uses to decide which tool to call, so it needs to be specific.

"Update the description for crm_account_summary to say: 'Returns a comprehensive summary of a CRM account including company details, primary contacts, active deals grouped by stage, recent activities, total revenue, and relationship health status. Use this for call preparation or account reviews.'"

Phase 8: Commit and publish

When everything works, commit and publish all five tools.

"Commit and publish crm_lookup_contact with the message 'Contact search by name, email, or phone'."

"Commit and publish crm_search_deals with the message 'Deal search with stage, value, and date filters'."

"Commit and publish crm_get_activity_feed with the message 'Recent activity feed with type and date filtering'."

"Commit and publish crm_account_summary with the message 'Full account summary for call prep and account reviews'."

Your CRM tools are now live. Anyone in your workspace can use them from their AI client.

What you built

  • crm_lookup_contact -- Searches contacts by name, email, or phone and returns clean contact details
  • crm_search_deals -- Searches deals by account, stage, value, and date range with formatted output
  • crm_get_activity_feed -- Returns recent activities filtered by contact, account, deal, or type
  • crm_account_summary -- Pulls together account details, contacts, deals, activities, and revenue into a single call-prep summary

Your account managers no longer need to spend the first ten minutes of every call clicking through the CRM. They ask their AI client for a prep sheet and get everything in one response.

Related guides