crisp-im / node-crisp-api

:zap: Crisp API Node Wrapper
https://docs.crisp.chat/guides/rest-api/
MIT License
99 stars 39 forks source link

Event not triggering: session:request:initiated #39

Closed dgroechel closed 2 years ago

dgroechel commented 2 years ago

I am working on an integration and session:request:initiated is not triggering when a new chat is started. I saw it was brought up in issue: https://github.com/crisp-im/node-crisp-api/issues/17 but no resolution. Other events such as message:send are working for me.

Steps done to troubleshoot:

Code example:

const Crisp = require('node-crisp-api')

const TOKEN_KEY = <'TOKEN'>
const TOKEN_IDENTIFIER = <'TOKEN'>

const CrispClient = new Crisp()

console.info('Authenticating...')

CrispClient.authenticateTier("plugin", TOKEN_IDENTIFIER, TOKEN_KEY);

console.info('Listening for events...')

CrispClient.on('session:request:initiated', (message) => {
  console.log("session started", message);
})
baptistejamin commented 2 years ago

Session:request:initiated is not a chat started event. This event is only used when you manually request to chat with a user from the MagicMap.

On 12 Jan 2022, at 21:49, David Groechel @.***> wrote:

I am working on an integration and session:request:initiated is not triggering when a new chat is started. I saw it was brought up in issue: #17 https://github.com/crisp-im/node-crisp-api/issues/17 but no resolution. Other events such as message:send are working for me.

Steps done to troubleshoot:

Incognito window to start a new chat Cleared out all crisp cookies and started a new chat Looked at source and session:request:initiated is included in DEFAULT_RTM_EVENTS Code example:

const Crisp = require('node-crisp-api')

const TOKEN_KEY = <'TOKEN'> const TOKEN_IDENTIFIER = <'TOKEN'>

const CrispClient = new Crisp()

console.info('Authenticating...')

CrispClient.authenticateTier("plugin", TOKEN_IDENTIFIER, TOKEN_KEY);

console.info('Listening for events...')

CrispClient.on('session:request:initiated', (message) => { console.log("session started", message); }) — Reply to this email directly, view it on GitHub https://github.com/crisp-im/node-crisp-api/issues/39, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGTRQZYLOFBTUAZGPW4GLLUVXSM5ANCNFSM5LZ6WHJA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.

dgroechel commented 2 years ago

Thank you! Is there an event for chat started/initiated in the API? I am not seeing anything in the docs and want to double check

valeriansaliou commented 2 years ago

No, there’s no such event. You’d need to catch a message:send event from the user and distinguish which one is the first for the session.