Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

feature: proactively start a ChatBot #162

Closed
samm81 opened this issue Nov 9, 2023 · 0 comments
Closed

feature: proactively start a ChatBot #162

samm81 opened this issue Nov 9, 2023 · 0 comments

Comments

@samm81
Copy link

samm81 commented Nov 9, 2023

hello again :)

opening an issue to discuss a feature proposal. I've already found a workaround, but I thought to start a discussion about this use case & a more kosher api for it.

I have a bot which I would like to start proactively - for a user (me) where the id is known ahead of time. this bot is a ChatBot and keeps state, messaging me every so often with a question which I respond to. so I want it to message me even if I haven't messaged it since the last restart.

after doing some digging my workaround is to just simulate sending it a message during application start:

bots = [{MyBot, [token: @token, max_bot_concurrency: 1]}]

children = [
  {Telegram.Poller, bots: bots},
  {Task,
   fn ->
     MyBot.dispatch_update(
       [{:init, %{"chat" => %{"id" => @chat_id_me}, action: :init}}],
       @token
     )
   end}
]

is this use case valid enough that maybe ChatBot should support it in a non-hacky manner?

I'm not exactly sure what the api would look like if so. maybe some function like ChatBot.start(chatbot_behavior, chat_id) (ChatBot.start(MyBot, @chat_id_me) in the example above), which would call Chat.Session.Supervisor.start_child/2 ?

hope this made sense!

Repository owner locked and limited conversation to collaborators Nov 9, 2023
@visciang visciang converted this issue into discussion #163 Nov 9, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant