Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error initialising Intercom in app.module.ts #22

Closed
newPrimitives opened this issue Oct 2, 2017 · 18 comments
Closed

Error initialising Intercom in app.module.ts #22

newPrimitives opened this issue Oct 2, 2017 · 18 comments

Comments

@newPrimitives
Copy link

I've installed Intercom throughnpm install ng-intercom@beta --save

When trying to import the Intercom in app.module.ts

import { IntercomModule } from 'ng-intercom';
..
    IntercomModule.forRoot({
      appId: "your_app_id", 
      updateOnRouterChange: trueDefault: `false`
    })
..

I get the following two errors:

Argument of type '{ appId: string; updateOnRouterChange: boolean; }' is not assignable to parameter of type 'IntercomConfig'.
Object literal may only specify known properties, and 'appId' does not exist in type 'IntercomConfig'.

I'm using Angular 4.

@newPrimitives
Copy link
Author

Okay, for some strange reason this now works, I've installed intercom again by using
npm install ng-intercom --save and it works, however the chat icon is not showing up. I'm also using the code from the readme with one addition, which is user_id.

@wbhob
Copy link
Contributor

wbhob commented Oct 2, 2017

The beta has been moved to the latest tag, so that has the latest version. The code from the readme should not take a user_id property in forRoot(), so that may be your issue. Are you getting any console logs or errors?

@wbhob wbhob added this to the 1.0.0 Final milestone Oct 2, 2017
@newPrimitives
Copy link
Author

I've used user_id in my component when I wanted to display the intercom chat widget. I used the exact same code as the example in readme and initially i get Intercom.init is deprecated and will be removed in a future release. Please use Intercom.boot. After I replace to this.intercom.boot nothing happens. No errors in the console. not widget in the corner.

@wbhob
Copy link
Contributor

wbhob commented Oct 4, 2017

To clarify: init works, and boot does not?

@newPrimitives
Copy link
Author

No, nothing works, the only difference is that init throws console warning and boot doesn't show anything. In both cases, I don't see the chat widget in the corner. Just to test it, I've included a vanilla JS code in my index.html file in the header and the chat button shows up, so it's definitely an issue with the library.

@wbhob
Copy link
Contributor

wbhob commented Oct 4, 2017

@newPrimitives init is deprecated in favor of boot to more closely match the IntercomJS API.

Can you please share a repo so I can see the issue?

@newPrimitives
Copy link
Author

It's a private repo but here's how I integrate it in the component:

In the app.module.ts

...

import { IntercomModule } from 'ng-intercom';

@NgModule({
  declarations: [
    ...
  ],
  imports: [
    ....
    IntercomModule.forRoot({ appId: "XXXX", updateOnRouterChange: true })
  ],
})

In the component:

....

import { Intercom } from 'ng-intercom';

...

export class ManageSpacesComponent implements OnInit {

constructor(private router: Router, private db: AngularFireDatabase, private auth: AuthService, public intercom: Intercom) {
 
  }

ngOnInit() {
    this.intercom.boot({
      app_id: "XXXXX",
      widget: {
        "activator": "#intercom" 
      }
    });
  }
}

For the sake of testing I just want to see a blue chat bubble in the bottom right corner.

@wbhob
Copy link
Contributor

wbhob commented Oct 4, 2017

just call this.intercom.boot, and appId should be app_id

@wbhob
Copy link
Contributor

wbhob commented Oct 4, 2017

If that is the issue, let me know so I can fix the docs

@newPrimitives
Copy link
Author

Unfortunately, not. My IntercomConfig looks like this:

export interface IntercomConfig {
    appId: string;
    updateOnRouterChange?: boolean;
    apiToken?: string;
}

so app_id instead of appId throws an error. Calling just this.intercom.boot() doesn't help either.

@wbhob
Copy link
Contributor

wbhob commented Oct 4, 2017

What version are you on?

@newPrimitives
Copy link
Author

npm-list shows ng-intercom@1.0.0-beta.6

@wbhob
Copy link
Contributor

wbhob commented Oct 4, 2017

Ok I’ll try to take a look tonight. Thanks for letting us know!

@newPrimitives
Copy link
Author

Thank you, let me know the results, really appreciate it.

@alexnoox
Copy link

I'm having the same issue. I've been investigating a bit:

  • To display the default button, the correct boot config option is #IntercomDefaultWidget:
widget: {
  activator: "#IntercomDefaultWidget"
}

The only issue that I encounter now is that I can't use alignment: 'left'. It is working when using the vanilla JS, but not using the lib.

@wbhob
Copy link
Contributor

wbhob commented Oct 10, 2017

I'm beginning to think it's something wrong with loading intercom asynchronously. I may need to dive in and investigate more. PRs would be accepted and greatly appreciated

@wbhob
Copy link
Contributor

wbhob commented Oct 14, 2017

Update: I can reproduce this error. It seems to be a whitelist error, but it could be something entirely different. Open to suggestions and PRs.

@wbhob wbhob closed this as completed in ea43863 Oct 14, 2017
@wbhob
Copy link
Contributor

wbhob commented Oct 14, 2017

Alright folks, I just released beta.7. Thanks for your patience! I've verified that it is working locally.

As an aside, make sure that you have whitelisted localhost so that Intercom knows requests are coming from you. I recommend using the TEST app so that you don't go into production with localhost whitelisted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants