Issues with update_presence Command & contact_last_seen_at API.
TLDR Mr.Bean struggles with "contact_last_seen_at" being 0 despite update_presence command. sojan_official explains it's updated based on user interactions with the chatwoot widget, not via direct APIs.
Aug 18, 2022 (16 months ago)
Mr.Bean
05:23 AMI was able find to the api but still contact_last_seen_at is 0
{ "account_id": 1,
"additional_attributes": {},
"agent_last_seen_at": 1660779366,
"assignee_last_seen_at": 1660779324,
"can_reply": true,
"contact_last_seen_at": 0,
"custom_attributes": {},
"inbox_id": 1,
"labels": [],
"muted": false,
"snoozed_until": null,
"status": "open",
"timestamp": 1660779324,
"unread_count": 0
}
Also when we update_presence using
{"command":"message","identifier":"{\"channel\":\"RoomChannel\",\"pubsub_token\":\"pubsub_token\"}","data":"{\"action\":\"update_presence\"}"}
we always get this error block invoke
chweb01.log:E, [2022-08-17T23:35:45.102798 #15] ERROR -- : Could not execute command from ({"command"=>"message", "identifier"=>"{\"channel\":\"RoomChannel\",\"pubsub_token\":\"pubsub\"}", "data"=>"{\"action\":\"update_presence\"}"}) [RuntimeError - Unable to find subscription with identifier: {"channel":"RoomChannel","pubsub_token":"pubsub"}]: /gems/ruby/3.0.0/gems/actioncable-6.1.5.1/lib/action_cable/connection/subscriptions.rb:75:in
find' | /gems/ruby/3.0.0/gems/actioncable-6.1.5.1/lib/action_cable/connection/subscriptions.rb:56:in
perform_action' | /gems/ruby/3.0.0/gems/actioncable-6.1.5.1/lib/action_cable/connection/subscriptions.rb:19:in execute_command' | /gems/ruby/3.0.0/gems/actioncable-6.1.5.1/lib/action_cable/connection/base.rb:89:in
dispatch_websocket_message' | /gems/ruby/3.0.0/gems/actioncable-6.1.5.1/lib/action_cable/server/worker.rb:60:in `block in invoke'sojan_official
10:32 AMref: https://www.chatwoot.com/docs/product/others/websocket-events#connect-to-chatwoot-websocket
-----
also looking into the code it seems like we dont have direct apis to update contact_last_seen_at . at the moment it is only updated based on a users interaction over the chatwoot chat widget. i have logged https://github.com/chatwoot/chatwoot/issues/5299 to track this
Mr.Bean
03:29 PMPLease see attached is the sequence of message send and received below.
Mr.Bean
03:31 PM{"command":"subscribe","identifier":"{\"channel\":\"RoomChannel\",\"pubsub_token\":\"4hNweRAeG8UuDV5jLEVYY8sC\",\"account_id\":1}"}
Response message with confirmation of subscription
{
"identifier": "{\"channel\":\"RoomChannel\",\"pubsub_token\":\"4hNweRAeG8UuDV5jLEVYY8sC\",\"account_id\":1}",
"type": "confirm_subscription"
}
Response message with presence update
{
"identifier": "{\"channel\":\"RoomChannel\",\"pubsub_token\":\"4hNweRAeG8UuDV5jLEVYY8sC\",\"account_id\":1}",
"message": {
"event": "presence.update",
"data": {
"account_id": 1,
"users": {
"1": "online"
}
}
}
}
Send presence update
{"command":"message","identifier":"{\"channel\":\"RoomChannel\",\"pubsub_token\":\"4hNweRAeG8UuDV5jLEVYY8sC\"}","data":"{\"action\":\"update_presence\"}"}
Mr.Bean
03:32 PMError in chatwoot weblogs
[2022-08-18T14:04:37.730115 #15] ERROR -- : Could not execute command from ({"command"=>"message", "identifier"=>"{\"channel\":\"RoomChannel\",\"pubsub_token\":\"4hNweRAeG8UuDV5jLEVYY8sC\"}", "data"=>"{\"action\":\"update_presence\"}"}) [RuntimeError - Unable to find subscription with identifier: {"channel":"RoomChannel","pubsub_token":"4hNweRAeG8UuDV5jLEVYY8sC"}]: /gems/ruby/3.0.0/gems/actioncable-6.1.5.1/lib/action_cable/connection/subscriptions.rb:75:in
find' | /gems/ruby/3.0.0/gems/actioncable-6.1.5.1/lib/action_cable/connection/subscriptions.rb:56:in
perform_action' | /gems/ruby/3.0.0/gems/actioncable-6.1.5.1/lib/action_cable/connection/subscriptions.rb:19:in execute_command' | /gems/ruby/3.0.0/gems/actioncable-6.1.5.1/lib/action_cable/connection/base.rb:89:in
dispatch_websocket_message' | /gems/ruby/3.0.0/gems/actioncable-6.1.5.1/lib/action_cable/server/worker.rb:60:in `block in invoke'Mr.Bean
03:33 PMMr.Bean
03:36 PM{{host}}/{{api_version}}/accounts/{{account_id}}/contacts/{{contact_id}}/conversations
{
"payload": [
{
"meta": {
"sender": {
"additional_attributes": {},
"availability_status": "offline",
"email": "[email protected]",
"id": 1,
"name": "First Last",
"phone_number": null,
"identifier": null,
"thumbnail": "null",
"custom_attributes": {},
"last_activity_at": 1660779317
},
"channel": "Channel::Api",
"assignee": {
"id": 1,
"account_id": 1,
"availability_status": "offline",
"auto_offline": true,
"confirmed": true,
"email": "[email protected]",
"available_name": "First Last",
"name": "First Last",
"role": "administrator",
"thumbnail": "null"
},
"hmac_verified": false
},
"id": 1,
Mr.Bean
03:36 PM{
"id": 350,
"content": "ok",
"account_id": 1,
"inbox_id": 1,
"conversation_id": 1,
"message_type": 1,
"created_at": 1660779324,
"updated_at": "2022-08-17T23:35:24.649Z",
"private": false,
"status": "sent",
"source_id": null,
"content_type": "text",
"content_attributes": {},
"sender_type": "User",
"sender_id": 1,
"external_source_ids": {},
"additional_attributes": {},
"conversation": {
"assignee_id": 1
},
"sender": {
"id": 1,
"name": "First Last",
"available_name": "First Last",
"avatar_url": "null",
"type": "user",
"availability_status": "offline",
"thumbnail": "null"
}
}
],
"account_id": 1,
"additional_attributes": {},
"agent_last_seen_at": 1660831522,
"assignee_last_seen_at": 1660831522,
"can_reply": true,
"contact_last_seen_at": 0,
"custom_attributes": {},
"inbox_id": 1,
"labels": [],
"muted": false,
"snoozed_until": null,
"status": "open",
"timestamp": 1660779324,
"unread_count": 0
}
]
}
Chatwoot
Indexed 2214 threads (46% resolved)
Similar Threads
Issue with Displaying 'Last Seen' Contact Information on Mobile App
sojan_official reports the "last seen" contact detail isn't displayed in the mobile app, but exists in the APIs. Mr.Bean provides the API command for "last seen", but encounters issues when the data doesn't update properly in the database.
Integrating Telegram bot with Chatwoot Through API
eveneasy tries to integrate telegram bot with Chatwoot through API but struggles with parameters. lourenco9597 guides them on creating intermediary API using chatwoot config details and API channel conversation.
Issues with Self-hosted Chatwoot and API-Created Conversations
hemantg_ was having issues with self-hosted Chatwoot API-created conversations not being fetched by front end widget. Suggestions and guidance were provided by muhsin_k and sojan_official, however, issue wasn't fully resolved in the given thread.
Updating Last Seen Message From Client Chatwoot Via Public APIs
shjba. asked how to update the last seen message from Client Chatwoot via public APIs. sojan_official informed there isn't an existing API for such a function and advised the query to be logged as a Github issue.
Auto-Display Interactive Chatwoot Menu Without Prompt
catalystjack wants to auto-display a Chatwoot menu without user prompts. sojan_official suggests webhook events. thinness2722 raises an issue and shares a GitHub link for tracking.