For many businesses, Drift can be the first line of communication with a potential customer.
In your use of Drift, you may have come across a need for custom external workflows and integrations with other applications. Drift has a number of prebuilt applications, such native integrations with Salesforce as well as Zapier hooks, but if none of the current features precisely fit, we also have an API to empower you to build!
In this example, I’ll go through the process of creating an external drift application that listens in on messages within the Drift conversations view will define words when the agent enters a certain trigger phrase. I have called this app Definely.
The source code is available on github: https://github.com/Driftt/definely, though you can follow along without viewing this. I’ll also mention here that the core bot source code is under 100 lines!
The Drift API
Before I get started, a lot of what I am going to be talking about can be found in our drift API documentation. You can find this here:
Creating a new App
With your drift account, log into our dev platform at http://dev.drift.com.
From here create a new application:
Once you log in, you’ll want to define the title and description/goal for the app, as well as a logo. For our app, I created a simple logo for definely which will show up on the apps page within Drift.
We’re all set! We can now install to drift, click here to install app to your organization’s account.
After clicking this, your app token will be revealed. This will be used by the server to authenticate requests into the drift message api.
Now, if you’re following along fully, I would recommend downloading the Definely app source code and starting the server (after following the readme)— the server will run locally on port 3001 by default.
For testing, I recommend exposing this for interaction with Drift via the tool ngrok:
ngrok - secure introspectable tunnels to localhost
ngrok secure introspectable tunnels to localhost webhook development tool and debugging tool
You can now expose your local server with the following ngrok command.
./ngrok http 3001
Take the public url of the form https://XXXXX.ngrok.io and plug into the event field — appending /api to this url as the callback route. Also be sure to set the event subscription to new_message as shown below.
Once the event subscription and callback urls are defined, you will need to add auth scopes to the app to be able to read and write to conversations. This is shown below.
If everything worked successfully, you should see your app and “Connected” visible in the My Apps view back from the main drift console.
Navigate to a live conversation and try it out! This is now active for your organization!
This is a simple example and you can do a lot more with our API’s such as building external integrations and pulling/inserting information into drift. We have customers that build things like CRM integrations, custom reporting tools, and external conversation management platforms. We’re continuing to build new features into the API and would love your feedback.
Exposing your app to other users
For your particular use case, it might be sufficient to leave the app internal, and that’s perfectly fine. We think the real strength of building custom apps comes from sharing your creation with other users — which can not only bring awareness to your brand, but also bring new opportunities for partnerships and value.
For a public app to be accepted, it will need to meet higher quality standards and be available on either a remote server or a service such as AWS lambda (and not ngrok unfortunately), we’ll review all apps that get submitted to us.
I won’t go into detail here on submission, but the submission process is well described in our docs:
Making a Public Integration
Want everyone on Drift to use your integration? We know we do! Once your app is published to Drift, everyone using…
Revisiting the App Source code
Joining our Dev Slack
Let us know what you build or if you have any questions!
Insert shareable gifs into the conversation view
Translate messages in the conversations view