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

Impossible from queue #2

Open
jdbaculard-ap opened this issue Oct 19, 2023 · 7 comments
Open

Impossible from queue #2

jdbaculard-ap opened this issue Oct 19, 2023 · 7 comments

Comments

@jdbaculard-ap
Copy link

Bonjour
Bravo pour le boulot.

Par contre depuis la queue, je souhaite renvoyer un message quelques minutes plus tard au bon user. Et ça ne fonctionne pas.

Est ce que cela devrait marcher depuis la queue ?

En gros la méthode say n'arrive pas à renvoyer le message au getUser()->getId()

@jalexmelendez
Copy link
Owner

jalexmelendez commented Oct 19, 2023

Hi, unfortunately I don't speak French, if you translate this message to English I'd be more than happy to help

@jdbaculard-ap
Copy link
Author

Hi thanks you

I want to send a message a few minutes later to the correct user. And it doesn't work.

the say method fails when i use getUser()->getId() saved in the DB in table "jobs"

Botman never display the message

Thanks

@jalexmelendez
Copy link
Owner

jalexmelendez commented Oct 19, 2023

If you are using laravel and the request object is present (not background jobs/queues) you can get the active session of the user by calling auth() and then chain the ID method auth()->id() or if you want to make something more complex like sending a message when the task or job is completed that could be harder because botman doesn't use websockets or long polling by default, in that case I would suggest you to maybe save the user_id to be notified and implement it using the broadcasting feature

@jdbaculard-ap
Copy link
Author

Thanks. It is not easy

Is the web widget compatible with laravel-echo?

@jalexmelendez
Copy link
Owner

Not out of the box, but you can wire them up! https://botman.io/2.0/web-widget

Go to the api Section and you can use the say method
image

@jalexmelendez
Copy link
Owner

Eg say something as the user, maybe a specific intent code to retrieve a specific message

@jdbaculard-ap
Copy link
Author

Yes it is OK, thank you

window.Pusher = Pusher;

window.Echo = new Echo({
  broadcaster: 'pusher',
  key: import.meta.env.VITE_PUSHER_APP_KEY,
  cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER,
  forceTLS: true
});

window.Echo.channel('channel-' + window.userId)
  .listen('.App\\Events\\ReplyEvent', (e) => {
    window.botmanChatWidget.sayAsBot(e.message)
  });

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

No branches or pull requests

2 participants