Last active
April 6, 2017 20:10
-
-
Save joel-thompson/d80d10bbb699f3cbc9f61c3a9f1d654b to your computer and use it in GitHub Desktop.
Ruby code for sending a message in Intercom, grabbing the conversation based on the message_id, then re-assigning that same conversation to a team. could be re-used to do other operations on that conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_user_id = '' # user_id of the person you are sending a message to | |
my_admin_id = '' # admin_id of the admin sending the message, and doing the re-assign | |
my_team_id = '' # admin_id of the team you are assigning to | |
# sends a message | |
message = intercom.messages.create({ | |
message_type: 'email', | |
subject: 'Hey there', | |
body: "What's up :)", | |
template: "plain", # or "personal", | |
from: { | |
type: "admin", | |
id: my_admin_id | |
}, | |
to: { | |
type: "user", | |
user_id: my_user_id | |
} | |
}) | |
# searches the user's conversations for those started with that message, grabs the first one | |
conversation = intercom.conversations.find_all(user_id: my_user_id, type: 'user').select {|convo| convo.conversation_message.id == message.id }.first | |
# assigns this conversation to the team | |
intercom.conversations.assign(id: conversation.id, admin_id: my_admin_id, assignee_id: my_team_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment