Genesys Cloud - Main

Β View Only

Sign Up

  • 1.  Agent Scripting - issues with nested variables

    Posted 5 hours ago

    Hello, all.  I have a small project where I am trying to compose a text string to send to a data action.  Within this text string are 0 to 3 scripter variables.  

    Assume that I have little practical knowledge of Scripter (I rarely use it, only for odd projects like this).  

    I have a variable {{ApptDateTime}}, to be set by agent using the calendar function.

    I have a scripter variable for agent email, {{Scripter.AgentEmail}}.

    I have a callback number {{PhoneReply}} variable that is static for this script.

    Some of these values need to be substituted into another variable, {{SMSBody}}.  An example:

    We are reaching out to confirm your appointment on {{ApptDateTime}}.  If you need to change your appointment, please contact me by email at {{Scripter.AgentEmail}} or call {{ReplyPhone}}.

    After the substitutions are made, SMSBody should contain the original text plus the substitutions.

    Can I do substitutions in the data action itself using the scripter variables to feed the data action (I can't seem to get them into the text body using ${input.ApptDateTime} in the data action or by using the variables in the scripter text) or should I have a RawBody, make the substitutions, and update a new variable SMSBody?

    Thanks in advance.


    #API/Integrations
    #Omni-ChannelDesktop/UserInterface

    ------------------------------
    Vikki Papesh
    Principal Genesys Cloud Developer
    Tandem Diabetes Care, Inc.
    ------------------------------


  • 2.  RE: Agent Scripting - issues with nested variables
    Best Answer

    Posted 3 hours ago

    Hi Vikki,

    You can make this much simpler - there is no need to build a "message inside another message" or a little nested-variable matryoshka. 😊

    In the button action, select:

    Data Actions β†’ Execute Data Action

    After selecting your Data Action, configure its SMSBody input as Interpolated Text.

    Genesys Cloud documents that Data Action inputs in a script can be populated with variables, static values, or interpolated text. Interpolated Text allows you to combine regular text with script variables, and Genesys inserts each variable's runtime value when the action executes. (Help My PureCloud)

    Your input could therefore be configured directly as:

    We are reaching out to confirm your appointment on {{ApptDateTime}}.
    
    If you need to change your appointment, please contact me by email at {{Scripter.Agent Email}} or call {{PhoneReply}}.
    

    The flow is simply:

    {{ApptDateTime}}          ┐
    {{Scripter.Agent Email}}  β”œβ”€β”€> Interpolated Text ──> SMSBody ──> Data Action
    {{PhoneReply}}            β”˜
    

    {{Scripter.Agent Email}} is the documented built-in variable for the current agent's email address. (Genesys Cloud Resource Center)

    So, in this scenario, I would skip RawBody and the additional substitution step. Let the SMSBody input itself be the template: Genesys Cloud will combine the fixed text with the current variable values and submit the completed input when the Data Action runs. (Help My PureCloud)

    Sometimes the easiest solution really is the right one: three ingredients, one Interpolated Text field, and off the message goes. πŸš€




    ------------------------------
    Fernando Sotto dos Santos
    Consultor de Atendimento Senior Grupo Casas Bahia
    ------------------------------



  • 3.  RE: Agent Scripting - issues with nested variables

    Posted 2 hours ago
    Edited by Vikki Papesh an hour ago

    Thank you, that advice worked perfectly for getting the data into the data action and into the SMS message using {{ApptDateTime}}.   It sends "2026-07-30T01:52:440000" which is a little less than friendly when using the scripter native calendar.  I'd like to display in the SMS as 07/30/2026 1:52 am.  

    Using the date variable value assigned by the date/time chooser, I created a new Dynamic Variable using this expression:
    formatDate(dateToMilliseconds({{ApptDateTime}}),  "MM/dd/yyyy h:mm a")

    This provides the desired format



    ------------------------------
    Vikki Papesh
    Principal Genesys Cloud Developer
    Tandem Diabetes Care, Inc.
    ------------------------------