ChatGPT and Salesforce Integration with Zapier

ChatGPT and Salesforce

There are lots of ways to integrate ChatGPT and Salesforce. We can integrate ChatGPT and Salesforce in different ways and by using other methods. We use ChatGPT API for the ChatGPT and Salesforce integration. In this blog, we’ll use ChatGPT API for ChatGPT and Salesforce integration by using Zapier. This will summarize a lead when it is created or updated and then, add the response in the description field of the Lead record.

ChatGPT is an Artificial Intelligence(AI) chatbot developed by an AI research agency, OpenAI. In its name, “chat” refers to a chatbot, while “GPT” stands for generative pre-trained transformer. It is trained with a large mass of data to generate a readable response to the user. We can use ChatGPT as a chatbot, virtual assistant, language translator, content generator, etc.

Zapier is an automation tool that helps you to connect different web-application and automate the tasks and data between them. It supports over 5000+ apps including Gmail, Salesforce, Slack, etc. It creates automated workflows named “Zaps” to connect two or more apps. While Salesforce is a cloud-based platform that uses CRM for managing marketing, sales, customer services, and many more.

Create a Zap for ChatGPT and Salesforce Integration to summarize the Lead record

In this Integration, we are going to ChatGPT API, Salesforce workflow rules, and outbound messages. We’ll also use Webhook by Zapier to catch POST or PUT URL to catch the hook. To create a Zap for ChatGPT and Salesforce integration, follow these steps:

1. Create a Zap for ChatGPT and Salesforce Integration

Step 1: First, log in to your Zapier account.

Step 2: Then, click the “Create Zap” button from the left sidebar of the dashboard.

Step 3: Afterward in the Trigger section, select “Webhooks by Zapier” as the trigger app, and choose “Catch Hooks” as the trigger event. Then, click the “Continue” button.

ChatGPT and Salesforce

Step 4: Now, leave the “Pick off a Child Key” field blank and click the “Continue” button. There is no need to fill this field for this integration. Then, it will generate a “Webhook URL” to send requests to. You need to configure your application(i.e. Salesforce) with that URL.

ChatGPT and Salesforce

Step 5: Then, copy the “Webhook URL” for configuring Salesforce.

2. Create a workflow rule in Salesforce

Step 1: Login to your Salesforce account and navigate to the “Setup” page.

Step 2: In the Quick Find box, type “workflow” and then select “Workflow Rules” under Process Automation > Workflow Actions.

ChatGPT and Salesforce

Step 3: Now, click the “New Rule” button to create a new workflow rule. Then from the dialog box that appears, click the “Continue with Workflow rules” button.

Step 4: Afterward, select the Lead object from the object dropdown and click the “Next” button.

Step 5: Here, provide a name in the “Rule Name” field of the Edit Rule section. Also, select “created, and every time it’s edited” in the Evaluation Criteria section.

Step 6: Then in the Rule Criteria section, select “formula evaluates to true” from the dropdown.

ChatGPT and Salesforce

Step 7: Now in the formula field, enter the formula given below and then click the “Save & Next” button.

ISNEW() || ISCHANGED( Status )

Step 8: Thereafter, click the “Add Workflow Action” dropdown and select “New Outbound Message” from the option. This opens the New Outbound Messages page.

Step 9: Here, provide a Name and Unique Name to the outbound message. And in the Endpoint URL field, paste the Webhook URL that you copied from the Zap earlier.

Step 10: Select the needed fields like FirstName, LastName, Description, Status, etc from the Available Fields multi-select picklist and add to the Selected Fields. Then, click the “Save” button and then the click “Done” button.

Step 11: Afterward, click the “Activate” button to activate the workflow rule.

3. Test your Zap trigger

Step 1: Create a new Lead or update the Status of any old Lead because it requires a record to test the Zap trigger. And then, go back to your Zap.

Step 2: Now, click the “Test Trigger” button. Then, you will get a result like below:

ChatGPT and Salesforce

Step 3: After all, click the “Continue” button for further processes. This will open the Action section.

4. Connect ChatGPT to the Zap to generate a response from AI

Step 1: In the Action section, select “ChatGPT” as the action app, and choose “Conversation” as the action event. Then, click the “Continue” button.

Note: You need the ChatGPT API key to connect your Zap to the ChatGPT. So, you need to create a ChatGPT API key using your ChatGPT account. An API key can only be seen and copied at the time of creation.

Step 2: Login to https://platform.openai.com/ using your ChatGPT account credentials.

Step 3: Now, click on the profile icon from the top-right corner of the page and select “View API Keys“. Then click the “+ Create new secret key” button to create a new API key.

Step 4: Copy the ChatGPT API key and navigate to your Zap.

Step 5: Here, click the “Sign in” button. A new window will open and ask you to access your ChatGPT account.

Step 6: Enter your API key in the API Key input field and click the “Yes, Continue to ChatGPT” button to allow access. Then, click the “Continue” button.

ChatGPT and Salesforce

Step 7: In the “User Message” field, enter the message for the AI as in the images below and click the “Continue

Step 8: Then, click the “Test Action” button to test the action of the Zap.

5. Connect Salesforce to the Zap to update the Description field with the response

Step 1: Click the “+” button under the Action section to add another Action.

Step 2: In this Action section, select “Salesforce” as the action app, and choose “Update Record” as the action event. Then, click the “Continue” button.

Step 3: Now, click the “Sign in” button. A new window will open and ask you to access your Salesforce account. Then, select “Production” as the Salesforce Environment and click the “Yes, Continue to Salesforce button”. This opens an Allow Access page.

ChatGPT and Salesforce

Step 4: In the Allow Access page, click the “Allow” button to allow access to your Salesforce account. And then click the “Continue” button.

Step 5: Select Lead in the Salesforce Object field. Also select the ID in the Record to Update field from the path:- Custom > Catch Hook in Webhooks by Zapier > Envelope Body Notifications Notification S Object Id.

Step 6: Then in the Description field, select the Assistant Response Message and click the “Continue” button.

Step 7: Now, test the Action by clicking the “Test action” button. This will return the test result like the below:

ChatGPT and Salesforce

Step 8: Finally, click the “Publish” button to publish the Zap. This will complete the integration.

Don’t forget, we have a team of Salesforce experts, so if you ever need support or have any questions, please get in touch, contact us at manish@bay20.com or call us at +91-8800519180