diff --git a/README.md b/README.md index 11e8f722..1cded3f5 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,8 @@ details. `startTour()` Your intercom account needs to support product tours +`startSurvey()` Your intercom account needs to support surveys + ### Events Subscribe to events in your app with event listeners: diff --git a/addon/services/intercom.js b/addon/services/intercom.js index 05efa5a2..ce48b060 100644 --- a/addon/services/intercom.js +++ b/addon/services/intercom.js @@ -263,6 +263,20 @@ export default Service.extend(Evented, { return this.get('api')('startTour', tourId); }, + /** + * If you would like to trigger a survey based on an action a user or visitor + * takes in your site or application, you can use this API method. + * You need to call this method with the id of the survey you wish to show. + * The id of the survey can be found in the “Additional ways to share your survey” + * section of the survey editor. + * @public + * @param {number} surveyId Survey ID to trigger + */ + startSurvey(surveyId) { + return this.get('api')('startSurvey', surveyId); + }, + + /** * Private on hide * @private diff --git a/tests/unit/services/intercom-test.js b/tests/unit/services/intercom-test.js index 28acce51..99b1367a 100644 --- a/tests/unit/services/intercom-test.js +++ b/tests/unit/services/intercom-test.js @@ -144,5 +144,9 @@ module('Unit | Service | intercom', function(hooks) { service.startTour(123); assert.equal(intercomStub.calledWith('startTour'), true, 'Intercom method called -- startTour'); sinon.assert.calledWith(intercomStub, 'startTour', 123); + + service.startSurvey(456); + assert.equal(intercomStub.calledWith('startSurvey'), true, 'Intercom method called -- startSurvey'); + sinon.assert.calledWith(intercomStub, 'startSurvey', 456); }); });