Skip to main content

1. Overview

The Ana x Salesforce integration connects your Salesforce org to Ana, giving you natural language access to your CRM data — accounts, opportunities, contacts, leads, and pipeline. Once configured, Ana can query deal stages, track pipeline progress, surface at-risk opportunities, and analyze sales performance directly in Ana.
Connect Salesforce to Ana to query and analyze your team’s CRM and sales data using natural language.

2. Prerequisites

You’ll need:
  • A Salesforce Enterprise or Developer Edition org you want Ana to query
  • Admin access to create and manage a Connected App
  • Python 3 installed locally (used once to generate a refresh token)
  • A TextQL account with permission to add API connectors
We recommend starting in a sandbox org and granting read-only scopes so you can validate the connection before pointing Ana at production data.

3. Capabilities

Once configured, Ana can:
  • Query open, active, or stalled opportunities across any pipeline or sales team in plain language.
  • Track how many deals are in each stage and identify which ones haven’t had recent activity.
  • Analyze lead sources, conversion rates, and sales performance over time.
  • Get a snapshot of account and contact data, including follow-up status and engagement history.
  • Surface at-risk opportunities and highlight records that need attention across your team.

4. Setup Instructions


Step 1: Create a Salesforce Connected App

  1. From your Salesforce welcome page, open the Setup Menu (gear icon, top right) and click Setup for current app.
  2. Search for App Manager in the Quick Find menu on the top left.
  3. Click New External Connected App.
  4. Name your app and enter a valid contact email in the required field.
  5. Enable OAuth and grant access to scopes. We recommend starting in a sandbox org and granting All scopes. Set the callback URL to http://localhost:8080/callback and check Introspect all Tokens to True.
Enable OAuth settings

Enable OAuth, add the localhost:8080 callback, and grant scopes. The callback is used to fetch a refresh token in Step 2.

  1. Configure the Flow Enablement and Security settings, then click Save to create the app.
  2. Navigate to the External Client App Manager page, find your app, and open its OAuth settings.
  3. Click Consumer Key and Secret, authenticate as prompted, then copy the Consumer Key and Consumer Secret — you’ll need them next.
Consumer Key and Secret

Copy the Consumer Key and Consumer Secret. Treat the secret like a password.

Treat the Consumer Secret like a password. Don’t commit it to source control or share it in plain text — paste it only into the secure field where it’s needed.

Step 2: Generate a refresh token

Salesforce access tokens are short-lived, so Ana authenticates with a refresh token. Its validity period is determined by the settings you configured on the Connected App. Run the following Python script, replacing YOUR_CONSUMER_KEY and YOUR_CONSUMER_SECRET with the values from Step 1:
The script will:
  1. Open your browser to the Salesforce login page.
  2. Start a local server on localhost:8080 to receive the OAuth callback.
  3. Exchange the authorization code for a refresh token.
  4. Display the refresh token and instance URL in your terminal.
If you’re using a sandbox org, update LOGIN_URL to your sandbox URL (e.g. https://test.salesforce.com or your custom domain).

Step 3: Add Salesforce as an API connector in TextQL

Salesforce connector in the TextQL API connectors grid

Salesforce highlighted in the TextQL API Connectors setup panel — select it to open the connector configuration form

  1. Go to app.textql.com and sign in.
  2. In the bottom left sidebar, click Connectors > APIs and create a new connector:
    • Name: salesforce_refresh_token
    • Value: Paste the refresh token from Step 2
  3. Click Save.
  4. Paste the following prompt into Ana, replacing YOUR_CONSUMER_KEY, YOUR_CONSUMER_SECRET, and YOUR_INSTANCE_URL with your values. The {{salesforce_refresh_token}} reference is automatically replaced with your stored secret.
If you’re using a sandbox org, update LOGIN_URL to https://test.salesforce.com or your custom sandbox domain.

Step 4: Verify the connection

Confirm everything is working by running the following script locally. Fill in the values from the previous steps:
  • CLIENT_ID: Your Consumer Key
  • CLIENT_SECRET: Your Consumer Secret
  • REFRESH_TOKEN: The refresh token from Step 2
  • INSTANCE_URL: The instance URL from the script output
  • LOGIN_URL: Your Salesforce login URL
A successful run authenticates with Salesforce and returns a few accounts. If it fails, refer to the Troubleshooting section.

5. Usage Examples

Once configured, you can ask Ana:
  • “Show me all open opportunities over $50k that haven’t been updated in more than 10 days.”
  • “Which deals are expected to close this quarter but have no recent activity?”
  • “Find all contacts tied to accounts with no opportunity in the last 90 days.”
  • “How many leads came from paid search vs. organic last quarter?”
  • “What’s the average time an opportunity spends in each stage this year?“

6. Troubleshooting

7. Security Notes

  • Follow the principle of least privilege — grant only the scopes Ana needs to query the data you care about. Read scopes are sufficient for analytics.
  • Treat the Consumer Secret and refresh token like passwords. Store them only in the secure connector field and never share them in email, chat, or tickets.
  • Refresh tokens remain valid based on your Connected App’s session settings. Rotate them if you suspect exposure, and re-run the Step 2 script to issue a new one.
  • If you no longer need the integration, revoke the Connected App in Salesforce and remove the connector from TextQL.
  • For more details, refer to the Salesforce OAuth documentation.

Need Help?

For further assistance, please contact support@textql.com.

Privacy Policy

For information about how we handle your data and protect your privacy, please review our Privacy Policy.