Answered

Initiate a conversation from an admin to a user

  • 3 October 2021
  • 8 replies
  • 662 views

Hi

 

I'm trying to do something that I thought should be simple, but am struggling to find a solution and was wondering if anyone had any suggestions?

 

Ultimately what I want to be able to do is:

 

When a user of my app takes a particular action in the app, I want to trigger a message to be sent from an admin to the user saying something like "Thanks for the submission, we're looking into it and will get back to you...". I also need this conversation to appear in the admin's inbox, essentially as a "ticket" that they need to work on and get back to the user at a later date.

 

I can't use the /conversations API to create a convo from admin to user because that direction isn't supported. (Conversations can only be created in the other direction, user -> admin).  

 

I get a little further with the /messages API. It allows you to send a message from an admin to a user but the problem is that it doesn't create a conversation so nothing shows up in the admin's inbox (so in my use case there's no "ticket" raised telling my admin that they have some work to do).  

 

When I say "it doesn't create a conversation", it actually does but it's some kind of hidden conversation that doesn't show up on the inbox. However if I open the user's contact record I can see the message as a conversation listed there. From there I'm able to manually infer the "hidden" conversation ID, and using that ID I can call the /conversation/<id>/parts API to assign the conversation to the admin after which it appears in their inbox - great, aside from the manual step to work out the conversation ID...

 

So my question is:

 

Is there a way to programatically get the conversation ID from a message created in the manner described above? (OR have I missed some other much more simple solution to achieve my original goal?)

 

 

NB: not really important to my issue, but worth mentioning there's either a bug or the documentation is incorrect on the /conversation<id>/parts API. The docs state for the "body" argument: "Optionally you can leave a note in the conversation for additional context to other teammates". However when used this doesn't appear as a note, but an actual message that the user will see.

icon

Best answer by Dan P12 11 January 2022, 14:38

View original

8 replies

Badge +1

Hi Parker,

 

Conversations in terms of the API are an inbound only created thing. This is something that your users create. In order to speak to your users from your side, you'll need to create an Outbound Message.

 

You can create Outbound Messages that show in-app via the API: https://developers.intercom.com/intercom-api-reference/reference#admin-initiated-conversation/p>

 

However, when it comes to retrieving these messages, it's more difficult. An outbound message is comparable to a seed for a conversation, they aren't conversations but they can grow and germinate into one. You can convert an Outbound message into a conversation by sending a reply in one.

 

You'll need to retrieve the Conversation ID of the Outbound Message to do this. This is quite tricky to do and you'll need to use the unstable CSV export feature to get the Conversation ID from the Outbound Message.

 

Once you've got the Conversation ID, you can re-open it by sending a note in the conversation. https://developers.intercom.com/intercom-api-reference/v0/reference#reply-to-a-conversation/p>

 

This is all quite long-winded to do and there are likely better ways of doing it:

  • You could open a conversation on behalf of the user behind the scenes using the Create a conversation API
  • You could have an app in your outbound message that prompts the user to take an action, thus allowing you to make changes to the conversation and reference it from within the app

 

The various strategies all have benefits and drawbacks so it's worth evaluating each and looking at your specific needs first.

 

I wish you the best of luck with your implementation.

Thanks @user1030​ ,

 

I looked into Outbound Messages, but had a few issues there too:

 

AFAICT an outbound chat also doesn't appear in any admin inbox until the user replies (so same issue for my use case where the admin will not be alerted to any work they need to do) and there's no way to add an auto assign step when creating the outbound message.

 

An outbound custom bot gives a bit more flexibility. It forces you to get a response from the user, and you can also add an auto assign step - so it should end up in an admin's inbox.

 

But I have another requirement (I didn't mention previously hoping to not overcomplicate): I need to be able to attach custom conversation data to the conversation (for later use in a canvas kit app on the inbox). What I've tried doing is:

 

1) Customer takes a particular action in my app (a "submission") and the app then fires an event using: Intercom.logEvent('submission', {some: 'dynamic', meta: 'data'})

2) The event triggers the custom bot to send the outbound message to the customer and assigns the conversation to an admin

 

The problem is I can't see a way to copy the dynamic metadata from the event into the conversation. Any thoughts on how to do this?

 

NB: it would also suffice if the event that triggered the conversation was available in the canvas kit POST data, but it doesn't seem to be there either

 

Thanks,

 

Dan

 

 

 

Userlevel 1
Badge

Hello @dan p12​ 👋, Welcome to Interconnect.

 

First of all best way to handle your first case will be to:

 

- Create User-Generated Conversation via API with the following text: Request Send (Create Conversation API);

- Then trigger assignment rule to appear to allow this conversation go to correct Inbox;

- Post Admin Reply via API.

 

In the following way, you will create a conversation that appears to Inbox and allows your agents to reply.

 

> The problem is I can't see a way to copy the dynamic metadata from the event into the conversation. Any thoughts on how to do this?

 

Please follow this guide:

Screen Shot 2021-10-04 at 7.42.57 PMSelect Event Metadata:Screen Shot 2021-10-04 at 7.43.15 PMAfter selecting it should look like this:

Screen Shot 2021-10-04 at 7.43.27 PM 

Please keep in mind that it requires 2-3 Min to appears after you send the event to Intercom.

Hi @roy s11​ ,

 

Thanks for your suggestions. Unfortunately the first case solution won't work for me as it will initiate the conversation from the user to the admin and I don't want it to be initiated in this direction. I'd like the very first message to be from the admin.​ 

 

On the second issue: copying event data, I don't think I phrased what I'm trying to do particularly well, sorry. I want to be able to copy the event data into the conversation data attributes, not use the event data in the conversation body.

 

https://www.intercom.com/help/en/articles/4323898-using-conversation-data-for-advanced-inbox-workflows/p>

 

Userlevel 1
Badge

@dan p12​ ,

 

Event sending is not related to the Conversation attribute, you can send an event but the customer maybe not even have started a conversation.

 

I'm suggesting to use User attribute for that, send Intercom following information via User attribute and then via Automation rule set them as a conversation attributes.

 

Screen Shot 2021-10-04 at 10.43.15 PMThe following workaround will avoid development and you can reach your goal much quicker.

Yeah, I'd be using the event to trigger a custom bot to start a conversation, and on that conversation I'd like to copy the event metadata attributes across to the conversation data attributes.

 

I don't think user attributes will work either as the metadata of the event is dynamic. On my app a users makes a "submission" which has a dynamically generated submission ID by the app. I ultimately want to react to that submission by starting a conversation with the user (initiated from an admin to the user) and for the conversation to have the submission ID in the conversation data attributes. The conversation also needs to appear in the admin's inbox.

 

I've tried with the API directly but it's not possible to start a conversation from admin to user. I can use the API to send a message outside the scope of a conversation from an admin to a user, but as there is no conversation scope nothing appears in the admin's inbox, plus there's no conversation metadata so neither of those options work.

 

My next thought was to create a custom bot that starts a conversation triggered by an event. I would then need to be able to copy the event metadata (the submission ID) across to the conversation.

 

Anyway, it looks like it's not possible to achieve my use case. Would be great if anyone managing the product backlog could comment on likelihood of any of the features discussed here being considered for implementation though?

 

Thanks for the suggestions @roy s11​ 

For anyone with the same/similar issue reading this: It looks like there has been an update to the /conversations endpoint that enables a work around....

 

You can now pass a "create_conversation_without_contact_reply": true flag when you create an admin initiated conversation. Doing this will make the conversation show up in intercom's inbox.

 

The only problem now is that despite passing true here, the response still doesn't contain the conversation ID. But this can be found via the conversation search endpoint. It's a bit hacky but it can work especially if you embed a unique id or phrase into the message somewhere to use in your conversation search query. i.e. for my use case I create the conversation with a subject of: "Thanks for your submission [ref:abc123]" where ref:abc123 is globally unique across my app. I can then search for conversations that contain the ref in the subject to get the conversation ID, which I then use to further modify the conversation, i.e. assign to whoever, or set custom attributes.

 

@eric f11​ Any idea if there are plans to return the conversation ID in the response when that flag is passed as true?

 

 

Userlevel 1

Hey @dan p12​, I don't know if this is something we plan to amend in future, but I'll certain make sure that your feedback gets flagged via our @Product Wishlist​ group!

Reply