Example Flows

This article shares some possible use cases your app could support, as well as an example flow that could support each use case. You're certainly not limited to these use cases, but they can be a helpful jumping off point as you plan your app's implementation.

Sync Messages from an External Service

Your app can enable business owners to communicate with their customers on any platform by syncing messages to Wix Inbox. The scenario below covers chat messages, but this flow could support integrating phone call logs, SMS services, chat sessions, or any other online or offline communication.

To do this, your app can follow this basic flow:

  1. Set up the external service's webhooks. When a "message sent" or "message received" webhook is triggered, parse the event data for an email address.

  2. Use Query Contacts to find a contact with the email address you extracted in step 1. You're looking for a contact ID here, so you can use the fields array to make sure the response only passes back id:

    Copy

    Any matching contacts are in the returned contacts array. An email address can belong to more than one contact, so your app must handle situations when multiple contacts are returned.

  3. Get the conversation ID with Get or Create Conversation.

    Set the participantId.contactId parameter to the id extracted in step 2:

    Copy

    You can get the conversation ID from conversation.id in the response.

  4. Use Send Message to add the new message to the contact's conversation.

    Set the conversationId parameter to conversation.id returned in step 3.

    In the body, pass the incoming message in a BASIC message type:

    Copy

Your app can also send messages sent on behalf of the business from the external chat tool. In those cases, change the visibility settings to match your requirements, and set direction to BUSINESS_TO_PARTICIPANT.

Add Contact Activities from Another Service

Your app can capture contact activities from another platform and display them in the contact's conversation in Inbox.

To do this, your app can follow this basic flow:

  1. Set up the external service's webhooks. When an event webhook is triggered, parse the event data for an email address.

  2. Use Query Contacts to find a contact with the email address you extracted in step 1. You're looking for a contact ID here, so you can use the fields array to make sure the response only passes back id:

    Copy

    The response includes matching contacts in the returned contacts array. An email address can belong to more than one contact, so your app must handle situations when multiple contacts are returned.

  3. Get the conversation ID with Get or Create Conversation.

    Set the participantId.contactId path parameter to the id extracted in step 2:

    Copy

    You can get the conversation ID from conversation.id in the response.

  4. Use Send Message to add the new message to the contact's conversation.

    Set the conversationId path parameter to conversation.id returned in step 3.

    In the body, pass the action in a MINIMAL message type:

    Copy
Did this help?