Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Identify SMS Message and last wrap-up code

    Posted 20 days ago

    Hi All,

    We have a scenario where agents complete and wrap up an SMS interaction, but the customer replies later and starts another conversation within the same messaging thread.

    We identified the wrap-up codes that represent a fulfilled or completed customer intention and added them to a data table. We also created a separate data table for keyword triggers such as "Thank you," "Thx," "Goodbye," and similar closing responses.

    The goal is to determine whether the customer's new SMS message should be treated as a new conversation or as a final/closing response to the previous completed interaction.

    I created a diagram showing how I think the logic could work, but I would like feedback on the cleanest configuration approach in Genesys Cloud.

    Proposed logic:

    1. Capture the customer's SMS body.

    2. Check the previous interaction within a defined timeframe.

    3. If there is no previous completed wrap-up code, route the customer to the normal bot greeting and menu.

    4. If there is a previous completed wrap-up code, compare it against the completed wrap-up code data table.

    5. If the wrap-up code matches, compare the customer's SMS body against the keyword trigger data table.

    6. If the message contains a closing keyword, send a closing response and disconnect.

    7. If the message does not contain a closing keyword, ask the customer whether they want to start a new conversation.

    8. If yes, send the bot menu.

    9. If no, send a closing response and disconnect.

    Please let me know if there is a cleaner or more supportable way to configure this.

    Thank you.



    #Architect

    ------------------------------
    Rechelle McConnell
    CHRISTIAN BROADCASTING NETWORK
    Outbound Dialer Systems Administrator
    ------------------------------


  • 2.  RE: Identify SMS Message and last wrap-up code

    Posted 19 days ago
    Edited by Chris Rodriguez 19 days ago

    Hi Rechelle, really clean diagram, and the logic is solid. A few thoughts on the implementation details.

    For the API check on the previous wrap-up code, the endpoint you want is POST /api/v2/analytics/conversations/details/query. Your request body should filter by the customer ANI using the address dimension, set your interval to the last 5 minutes using ISO 8601 format, order by conversationEnd descending so you always get the most recent completed interaction first, and set pageSize to 1 since you only need the last one. From the response, you pull the wrapUpCode from the participants array where purpose equals agent. Here is a starting point for the request body that you will likely need to tweak based on your specific environment and use case:

    **Testing needed**

    {
      "interval": "2026-05-23T00:00:00.000Z/2026-05-23T00:05:00.000Z",
      "order": "desc",
      "orderBy": "conversationEnd",
      "paging": {
        "pageSize": 1,
        "pageNumber": 1
      },
      "segmentFilters": [
        {
          "type": "and",
          "predicates": [
            {
              "type": "dimension",
              "dimension": "address",
              "operator": "matches",
              "value": "${Flow.customerANI}"
            }
          ]
        }
      ]
    }

    Note: the interval needs to be dynamic in your actual data action; you would calculate the current time minus 5 minutes and pass it in as a variable rather than hardcoding the date. And as mentioned, this is a starting point, so expect some tweaking.

    Make sure your data action handles the empty array case cleanly because if no conversation is found within the window, you want it to return a clear empty string, not throw an error that dead-ends the customer. Default to the normal bot greeting on any failure path.

    We use a very similar pattern in our chatbot, where a data action fires at the top of the inbound flow to pull context before the customer even types their first message, and in our preferred agent routing, where a data action queries an external system and branches the flow based on what comes back. Same concept you are applying here, front-load the context check so the routing decision is already made before the customer has to do anything.

    For the keyword data table, make sure you store all keywords in lowercase and apply a ToLower() expression on the SMS body before the comparison. Otherwise, you will miss variations like THANKS versus Thanks versus thanks, and your detection will feel inconsistent in production.

    The 5-minute window is your most sensitive variable. Worth making it configurable in the data table itself with a column like WindowMinutes, so you can tune it without republishing when requirements change.

    One simplification worth considering on step 7, instead of asking the customer if they want a new conversation, flip the default and assume it is a new conversation unless the SMS body matches a keyword. That removes the confirmation step entirely for most customers and only intercepts true closing responses. Cleaner experience and fewer messages in the thread.



    ------------------------------
    Chris Rodriguez
    Contact Center System Administrator
    ------------------------------



  • 3.  RE: Identify SMS Message and last wrap-up code

    Posted 16 days ago

    Thank you so much Chris. Awesome!



    ------------------------------
    Rechelle McConnell
    CHRISTIAN BROADCASTING NETWORK
    Outbound Dialer Systems Administrator
    ------------------------------