-
Notifications
You must be signed in to change notification settings - Fork 12
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
Nothing happens until a button is pressed multiple times #29
Comments
I haven't seen this before, but payloads can be a little tricky because of some unexpected things. I can't say for sure until you paste your class BotController < Stealth::Controller
before_action :current_user
def route
if current_message.payload.present?
handle_payloads
current_message.payload = nil
return
end
if current_session.present?
step_to session: current_session
else
step_to flow: 'hello', state: 'say_hello'
end
end
private
def handle_payloads
case current_message.payload
when 'developer_restart', 'new_user'
step_to flow: 'hello', state: 'say_hello'
when 'something_else'
step_to flow: 'some_other', state: 'state'
end
end
def current_user
@current_user ||= begin
user = User.find_by(recipient_id: current_user_id)
unless user.present?
user = persist_current_user
end
user
end
end
def persist_current_user
fb_profile = Stealth::Services::Facebook::Client.fetch_profile(
recipient_id: current_user_id
)
User.create!(
recipient_id: current_user_id,
first_name: fb_profile['first_name'],
last_name: fb_profile['last_name'],
profile_pic: fb_profile['profile_pic'],
)
end
end The key is that payloads are handled globally like this before the user is even routed. So in the |
It's rather plain class BotController < Stealth::Controller
include Logging
helper :all
def route
logger.info "---------------------------------------DUPA: #{current_message.message}"
if current_session.present?
step_to session: current_session
else
step_to flow: 'hello', state: 'say_hello'
end
end
end |
I have updated to a similar version of what you have but I still had to click the button twice to get any reaction at all. 23:24:01 web.1 | [incoming] Received webhook from facebook
23:24:35 web.1 | [incoming] Received webhook from facebook
23:24:35 sidekiq.1 | 2019-02-10T22:24:35.871Z 26377 TID-gpuf4l1n5 Stealth::Services::HandleMessageJob JID-26af63a1cc4f6a87026ce9bc INFO: start
23:24:35 sidekiq.1 | I, [2019-02-10T23:24:35.872147 #26377] INFO -- : ---------------------------------------DUPA:
23:24:35 sidekiq.1 | [previous_session] User 1023058087818337: skipping setting to hello->get_selection because it is the same as current_session
23:24:35 sidekiq.1 | [session] User 1023058087818337: setting session to hello->get_selection
23:24:35 sidekiq.1 | [previous_session] User 1023058087818337: setting to hello->get_selection
23:24:35 sidekiq.1 | [session] User 1023058087818337: setting session to reservation->ask_for_date
23:24:36 sidekiq.1 | [facebook] Transmitting. Response: 200: {"recipient_id":"1023058087818337","message_id":"m_J1RYWM26l8sXlDV-7oRM9TBWw9_3akcE0vMYl82HgIXe5he61iXZ7A3S2T5MTuC9vXR7_1NEB8s_wFZjIgYzWw"} |
@mgomes I can give you developer access to the facebook application if this would help you with anything since it's something I'm doing in my spare time |
Can you confirm that for each time you press the a button you get a corresponding webhook from Facebook? Let's start there. I think something is up with how those are coming in. |
Yes, every time I press a button, write a message I get an information
about incoming webhook in Stealth server console.
pon., 11 lut 2019, 17:17: Mauricio Gomes <[email protected]>
napisał(a):
… Can you confirm that for each time you press the a button you get a
corresponding webhook from Facebook? Let's start there. I think something
is up with how those are coming in.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#29 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGPH_fSywm-Y5XRtYj6CVQQ8azoIgUxjks5vMZesgaJpZM4azEjo>
.
|
In my
say_hello.yml.erb
file I have the following replyThe options do show up, clicking them sends the message but nothing happens in my bot for some reason.
The only thing I get in the Stealth server log is:
Only after clicking it more than once (sometime it takes 2 time, sometimes I have to click on it over 9000 times) something does happen:
What am I doing wrong?
The text was updated successfully, but these errors were encountered: