jalexmelendez / botman-studio-9

Updated version of botman studio using laravel 9, Vite and TALL stack ready.
MIT License
9 stars 3 forks source link

Impossible from queue #2

Open jdbaculard-ap opened 11 months ago

jdbaculard-ap commented 11 months ago

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 commented 11 months ago

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

jdbaculard-ap commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

Thanks. It is not easy

Is the web widget compatible with laravel-echo?

jalexmelendez commented 11 months ago

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 commented 11 months ago

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

jdbaculard-ap commented 11 months ago

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)
  });