Calling Extensions SDK
Please note: Our calling app partners no longer need to create and update call engagements manually; HubSpot will do it for them. Learn more here.
The Calling Extensions SDK allows apps to provide a custom calling option to HubSpot users directly from a record in the CRM.
A calling extension consists of three main components:
- The Calling Extensions SDK, a JavaScript SDK that enables communication between your app and HubSpot.
- The calling settings endpoints, which are used to set the calling settings for your app. Each HubSpot account that connects to your app will use these settings.
- The calling iframe, which is where your app appears to HubSpot users and is configured using the calling settings endpoints.
For more information on the in-app calling experience, review this knowledge base article. Once your calling extension-enabled app is connected to HubSpot, it will appear as an option in the call switcher whenever a user makes a call from HubSpot.
If you don't have an app, you can create one from your HubSpot developer account. If you don't already have a HubSpot developer account, sign up for one here.
Please note: only outgoing calls are currently supported.
You have the option to test the Calling Extensions SDK on two different demo apps:
- The demo-minimal-js features a minimal implementation of the SDK using JavaScript, HTML, and CSS. View how the SDK is instantiated in index.js.
- The demo-react-ts features a real-life implementation of the SDK using React, TypeScript, and Styled Components to act as a blueprint for your app. View how the SDK is instantiated in useCti.ts.
Please note: these demo apps aren't fully functional calling apps and use mock data to provide a more realistic experience.
You can run the demo apps with or without installation. To install the demo on your local environment:
- Install Node.js on your environment.
- Clone, fork, or download the ZIP of this repository.
- Open your terminal, and navigate to the root directory of the project.
- Run one of the following commands:
- For the
demo-minimal-js
:
- For the
npm start
command will automatically open a new tab in your browser at https://localhost:9025/, and you may need to bypass a "Your connection is not secure" warning in order to access the application.
- Navigate to your records:.
- Contacts: In your HubSpot account, navigate to Contacts > Contacts.
- Company: In your HubSpot account, navigate to Contacts > Companies.
- Open your browser's developer console, and run the following command:
- If you've completed the installation steps, for the
demo-minimal-js
or thedemo-react-ts
:
- If you've completed the installation steps, for the
- If you've skipped the installation steps:
- For the
demo-minimal-js
:
- For the
- For the
demo-react-ts
:
- Refresh the page, and click the Call icon in the left sidebar. Click the Call from dropdown menu, and select the name of the demo app from step 2 (e.g. Demo App Local, Demo App JS, Demo App React).
- Click Call to see how the demo app integrates with HubSpot via the Calling Extensions SDK. You can also see the events logged to your browser's developer console.
To add the Calling Extensions SDK as a Node.js dependency to your calling app:
- For npm, run:
The Calling Extensions SDK exposes a simple API for HubSpot and a calling app to exchange messages. The messages are sent through methods exposed by the SDK and received through eventHandlers
. You can find a full list of the available events in the Events section.
The following is a description of the events:
- Dial number: HubSpot sends the dial number event.
- Outbound call started: App notifies HubSpot when the call is started.
- Create engagement: HubSpot creates a call engagement with minimal information if requested by the app.
- Engagement created: HubSpot created an engagement.
- EngagementId sent to App: HubSpot sends the
engagementId
to the app. - Call ended: App notifies when the call is ended.
- Call completed: App notifies when the user is done with the app user experience.
- Update engagement: App fetches the engagement by the
engagementId
, then merges and updates the engagement with additional call details. Learn more about updating a call engagement via the APIor via the SDK.
To begin, create an instance of the CallingExtensions
object. You can define the behavior of your extension by providing an option's object when you create your extensions instance. This option's object provides an eventHandlers
field where you can specify the behavior of your extension. The following code block illustrates the available options and event handlers you can define:
In order to launch the calling extensions iFrame for end users, HubSpot requires the following iFrame parameters.
Using your API tool (e.g. Postman), send the following payload to HubSpot's settings API. Ensure you get the APP_ID of your calling app and your app DEVELOPER_ACCOUNT_API_KEY.
isReady
flag indicates whether the app is ready for production. This flag should be set to false during testing.
You can override any of your extension settings for testing purposes. Open your browser developer console from a HubSpot tab, edit the settings below, and run the command:
Once you have set your app settings using the calling settings endpoint, use the PATCH endpoint to change isReady
to true.
The final step once your app is setup is to list your calling app in the HubSpot marketplace. You can find more details here . You can also choose not to list it in the marketplace if this application is for internal use only.
Property | Type | Description |
---|---|---|
isLoggedIn
| Boolean | Checks if a user is logged in or not. |
engagementId
| Number | A HubSpot created engagement ID. |
Property | Type | Description |
---|---|---|
callStartTime
| Number | Start time of call, in milliseconds. |
createEngagement
| Boolean | Whether HubSpot should create an engagement for this call or not. When true, HubSpot will respond with onCreateEngagementSucceeded or onCreateEngagementFailed. |
toNumber
| String | The recipients phone number. |
fromNumber
| String | The caller's number. Required parameter. |
Property | Type | Description |
---|---|---|
externalCallId
| String | A calling app created call ID. Used to enable calling in help desk |
Property | Type | Description |
---|---|---|
externalCallID
| String | A calling app created call ID. Used to enable calling in help desk |
engagementId
| Number | A HubSpot created engagement ID. |
callEndStatus
| Enumeration | The status of the call when ended. Statuses available:
|
hideWidget
property will be ignored when the user is in a task queue with the Call
task type.
Property | Type | Description |
---|---|---|
engagementId
| Number | A HubSpot created engagement ID. |
hideWidget
| Boolean | Whether the widget should be hidden when the call is ended. Optional parameter. Defaults to true. |
engagementProperties
| String | Opt in to hs owned engagements by adding properties. Causes HubSpot to respond with onUpdateEngagementSucceeded or onUpdateEngagementFailed. |
externalCallId
| Number | A calling app created call ID. Used to enable calling in help desk. |
Property | Type | Description |
---|---|---|
message
| String | Error message to be displayed in the alert popup. |
Property | Type | Description |
---|---|---|
height
| Number | Desired height of the call widget. |
width
| Number | Desired width of the call widget. |
The extensions
object provides the following event handlers that you can invoke when receiving messages in HubSpot or to specify other associated behavior. See examples below.
Message indicating that HubSpot is ready to receive messages.
onDialNumber
event will provide a payload that includes all the pertinent fields associated with the call. These fields are detailed in the table below:Property | Type | Description |
---|---|---|
phoneNumber
| String | The phone number of the person that the HubSpot user called. |
ownerId
| String | Number | The ID of the logged in user (in HubSpot). |
subjectId
| Number | The ID of the subject. |
objectId
| Number | Object type of the phone number. |
objectType
| String | The object type associated with the phone number that was dialed (e.g., the phone number of the contact or company). The possible values here are |
portalId
| Number | The ID of the HubSpot portal. |
countryCode
| String | The country code of the phone number. |
calleeInfo
| Array | Information about the callee. Should include the following:
|
startTimestamp
| Number | Timestamp of the start of the call. |
toPhoneNumberSrc
| String | The name of the phone numbers' property in HubSpot. The property can be a standard property value or a custom property. For example, a contact may have three contact phone numbers, one may be labeled Office, another may be labeled Personal and the other may be labeled Mobile. |
Property | Type | Description |
---|---|---|
engagementId
| Number | A HubSpot created engagement ID. |
Property | Type | Description |
---|---|---|
engagementId
| Number | A HubSpot created engagement ID. |
objectCoordinates
| Object coordinates | References a portalId , objectId , and objectTypeID . |
Property | Type | Description |
---|---|---|
engagementId
| Number | A HubSpot created engagement ID. |
externalCallId
| String | A calling app created call ID. Used to enable calling in help desk |
Property | Type | Description |
---|---|---|
engagementId
| Number | A HubSpot created engagement ID. |
externalCallId
| String | A calling app created call ID. Used to enable calling in help desk |
The calling app should handle authentication.
Is Calling Extensions hosted on a CDN?
Yes. You can install the Calling Extensions SDK via jsDeliver. For example, to install calling-extensions-sdk@0.2.2, you can use https://cdn.jsdelivr.net/npm/@hubspot/calling-extensions-sdk@0.2.2/dist/main.js.
When should an engagement be created versus updated?
A user can initiate a call from inside the HubSpot UI and outside the HubSpot UI (e.g. mobile app, redirected number, etc.) If a call is initiated from within HubSpot UI, HubSpot will create a call engagement and send the engagement to the calling app. Once the call finishes, the call app can update this engagement with additional call details. If a call is initiated outside of HubSpot UI, the app should create the call engagement.
What scopes are required as a part of the integration?
Add contacts and timeline scopes are required. These scopes ensure your application has access to contacts and the ability to create and update call engagements in the CRM.
Can this functionality be added to an already existing application in the marketplace or do I create a new app?
If you already have an existing app that serves the calling use case then you can directly add this functionality to your existing app. All customers who already have your app installed will get access to this new functionality without having to install the app again.
Can I integrate my existing soft phone application in the SDK?
Yes, integrating your existing soft phone application should be very easy. Just follow the steps in the documentation above to have your application up and running.
Can users use multiple integrations at the same time?
Yes, users can use multiple third-party calling integrations at the same time. They can use the provider switcher presented after clicking on the call button to seamlessly switch between providers.
Can free users install app integrations?
Yes, all users can install the app.
If a user already has my app installed, does the integration automatically show up?
Yes, if a user already has installed your app, and you are updating the same app with the calling extensions, the integration will automatically show up. Currently, there is no way for the developer to enable the calling app only to a subset of customers.
Can any user install or uninstall an app?
No, only users who have necessary permissions can install and uninstall an app. Learn more about how to review a user's permissions.
Can I create a custom calling property?
Yes, you can create a custom calling property using the properties API.
Can I place a call from a custom object?
Yes, calling integrations can place calls from custom objects as long as they only use the SDK to create the call. Each integration will need to verify that they only use the Calling SDK to create calls and to notify HubSpot in the outgoingCall
event.
First, verify that the integration is using the Calling SDK to create engagements in the outgoingCall event:
If createEngagement
is true, learn how to update your app information here.
Here is the example for the entire outgoingCall
event:
Thank you for your feedback, it means a lot to us.