In this guide you'll learn how to connect to a PostgreSQL database from FactBranch and design data outputs for the FactBranch app in Zendesk. Using FactBranch and SQL queries you can show your agents customer information whenever they open a ticket.
FactBranch is an app for Zendesk that loads customer info from a variety of external sources and displays them in Zendesk next to the ticket. In this blog post we'll discuss how to connect FactBranch to your Postgres database. FactBranch queries the database and shows the results to your agents. In Zendesk the FactBranch app looks like this:
If you don't have anybody at your company who can write an SQL query, please get in touch with firstname.lastname@example.org and our team will gladly help you out.
If you know SQL, let's dive right into it and connect to your database.
FactBranch has a flexible but easy-to-use setup wizard to create a connection to your database. First, you define an SQL query and then you design how the result(s) should be displayed in the FactBranch app in Zendesk.
If you haven't done so already, create a FactBranch account. You don't need a credit card to sign up and each account comes with a 14 day free trial.
After creating an account you'll see a list of connections available in FactBranch. Select PostgreSQL.
Now enter your database credentials.
We recommend to create a special database user for FactBranch that has as few permissions as possible.
If you have to allow external IP addresses in your database server's firewall, activate "Use a static IP when making database requests" and allow access from the IP displayed in the yellow box. You might have to talk to your IT team to make this happen at your company.
Once you're ready to test the connection, hit "Test connection".
You should either get an error message telling you what went wrong – or a green "Success" box. Either fix the errors and test again, or click "Save and continue".
This is the SQL query editor:
The big black field in the center is the editor itself, giving you lots of space for even complicated queries. On the right you can test your query by searching for an email address.
First enter the query you'd like to run each time an agent opens a ticket. You can use any SQL that your server understands.
To search for an email address, make sure to include a WHERE clause like this:
SELECT * FROM customer WHERE customer.email=%(email)s
The important part is "%(email)s". When FactBranch queries your database. This part will be replaced by the email address you want to find.
Once you're happy with the query, test it on the right by entering an email address you know exists in your database and hitting "Search".
Make absolutely sure that each field has a unique name. For example if your query produces two columns called "ID", use SQL like "AS customer_id" and "AS order_id" to make them unique.
Once you get the desired results, click "Continue" in the top right corner of the page to get to the Output Designer.
In the final step you can rearrange the items and rename their labels.
The area on the right shows you a preview how the result will look in Zendesk. If you want to rename a label, select the label-field in the editor and simply make the changes.
To change the order, drag one of the items up or down in the editor in the center. You can grab the items anywhere except the input-field.
Check the preview on the right. And once you're happy with the results, click "Finish". You'll be redirected to your list of integrations.
If you haven't installed the FactBranch Zendesk app yet, you'll see a blue box asking you to install the app.
Copy the FactBranch API-key and then click on the button Install FactBranch in Zendesk. On the Marketplace page hit the Install button and when prompted, paste the API-key you've copied just now.
Click the Install button one last time.
Now when you open a ticket, FactBranch looks up the customer in your Postgres database and displays their info in the ticket sidebar.
If you have questions or need additional features, please get in touch via email@example.com. We'd love to hear from you and we'll reply to your email within a few business hours.