Genesys Cloud - Main

 View Only

Discussion Thread View
  • 1.  get specific data from email body and ideally transform it into a callback

    Posted 12-24-2021 09:28
    Hello,

    One of my customer is using connected devices that send an automatic email when an event is triggered.

    These emails will arrive on a specific email address and follow a template (basically the ID of the device is the first word of the body).

    What I would like to do is to take the first "word" (in fact, a number) of the body (every character before the first space) and check on a data table if there's a phone number associated.

    A) nothing associated : forward email to a queue for manual treatment by agent
    B) phone number associated : 
    B1) best scenario : transform the email into a callback to the associated phone number and put it on queue
    B2) acceptable scenario : present the email on the queue with a script that show the phone number to be called

    My questions are :
    1) Do one of you know how I can do the first check (select the first word of the body) on Architect ?

    2) Is scenario B1 (transform into callback) possible, and then how ?

    Thanks in advance to all of you !
    #DigitalChannels
    #Routing(ACD/IVR)

    ------------------------------
    Pierre Pirson
    Proximus PLC
    ------------------------------


  • 2.  RE: get specific data from email body and ideally transform it into a callback

    Posted 12-26-2021 14:37
    Hello Pierre,

    I tried to implement your scenario as you requested.

    Configuration :
    Email
    Below, I used a simple ID (123456789) to start my email Body followed by a string.


    Data Table
    The first column will be the Device ID and the second one will hold the phone number to be used for callback.
    Architect / Inbound Email Flow
    The first step is to extract or select the first word of the body.
    To do so, you can use the combination of 2 built-in functions under Architect : 
    FindString : returns the location of a specified occurrence of a String within a String.
    Substring : gets part of a String that starts at a specified position and has the specified length.

    In your example, you need to search for the first occurrence of the first space after the Device ID.
    FindString(Email.Message.body," ") 
    where :
    Email.Message.body is the Email body as plain text.
    Returned Value is an Integer (zero-based index)

    Once you have the index of the space character, you can use it inside the Substring function as the following to extract only the ID :
    Substring(Email.Message.body,0,FindString(Email.Message.body," "))

    This function takes 3 parameters :
    String text : The source String from which the substring will be taken (Email.Message.body)
    Integer start : The starting position of the String in the text parameter. The first position is 0.
    Integer length : The length of the desired substring.

    Then, we can use the ID as an input to the Data Table in order to make a lookup.
    Below, the Inbound Email Flow:

    The first Set Participant Data is only for logging purposes to show you how to extract the ID. (you can start your flow directly with the Data Table Lookup)
    The same formula is used as an input for The Data Table in order to look for the Device ID. Then store the Phone Number found in a variable called Flow.Phone

    First use case : No phone is associated
    you can use the Decision block to check if the variable holding the phone number is empty or not (Flow.Phone). To do so, you can use the built-in function IsNotSetOrEmpty which determines whether a value is NOT_SET or empty, then it returns a boolean.
    If it is empty, then under the Yes path, you can use Transfer to ACD action to route the email interaction to the queue as you requested.

    If it is not empty, then make a callback instead of the email.
    How to make a callback ?

    You cannot create a callback from an Inbound Email flow by only using the built in actions (such as Create Callback Action) since they are different media types.
    But you can use a Data Action to create a callback instead. 
    it is a POST request to this endpoint /api/v2/conversations/callbacks
    with the following inputs :
    Queue_ID : Queue's ID to which you would like to route the callback
    CB_Number : the phone number used for the callback (the phone found in the Data Table)


    Results :

    1 - No Phone Associated :

    In this case, as you can see, The Device ID was successfully extracted from the Inbound Email. The Phone Variable is set to empty since nothing was stored in the Data Table. As expected, the email was routed to the Queue.

    2 - Phone Associated :


    Under Performance/Queue Activity, you can see a waiting Callback interaction well created 

    Under Performance/Interactions, you can see both inbound email and the created callback interactions 

    Regarding the logs, the Phone variable now is set to Not Empty and Callback set to Success which means that the Data Action was successfully executed. 



    Note:
    - I didn't go into details regarding all the different scenarios where the Device ID is not found in the Data Table and all the different branches. I'll let you customize it depending on your needs.
    - If you would like to assign a skill to the Callback, a script, priority... these are optional but you can adjust the data actions inputs if it is needed in your design.

    Let me share with you the Action Contracts and Configuration of the Data Action, so you can use it right away and test it





    I apologize if my answer is quite long, but I wanted to breakdown every detail.
    I hope it is clear and it answers your questions :)

    Thank you,

    Kind Regards,



    ------------------------------
    Charaf Eddine Chemlal
    NTT France SASU
    ------------------------------



  • 3.  RE: get specific data from email body and ideally transform it into a callback

    Posted 12-27-2021 03:24
    Hello,

    Thanks a lot for your help, I'll implement it now.

    rgds,

    Pierre

    ------------------------------
    Pierre Pirson
    Proximus PLC
    ------------------------------



Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources