Functions and variables

feature_request

#1

Hi!

I’m trying to implement something like “gateway” in the front of my bots: use ID (currently lead ID from CRM that will use to save answers in chats) passed by URL param else use email passed by URL too else ask user to provide the email. And dispaly some friendly error messages and advices like call the support or try with another email again.
It’s very simple logic on most programming languages but I stuck with it at the Tars.

  1. There are no functions for code reusing and I need to make all “gateway” gambits from the scratch on all my bots.

  2. There are no variables and assigments and I don’t know how to solve situations like this:

  • If id param passed by URL I need to referrence it as {{urlp.id}}
  • if id param not passed by URL but finded by email with external CRM request - {{pre.getIDByEmail.result[0].ID}}
  • if email passed by URL - referrence it as {{urlp.email}}
  • if email not passed by URL but asked on the conversation - referrence it as {{ursp.email}}

But I want the one variable independently of request type, something like

if(urlp.id is defined) {
 id = urlp.id
} else {
 id = pre.getIDByEmail.result[0].ID
}

So I have the only one idea - use FaaS (AWS Lambda and so on) for all “gateway” logic and call it by API config in the Tars.

What the Tars team think and paln about this situations?


#2

@mvs

Have you seen this?


#3

Yes, but it’s doesn’t relate to my sutuiation.


#4

@mvs The thing that you want to achieve, as i understood from your description, can be achieved from the conditional jump feature. You need to make the proper conditional branches in an initial gambit and then make seperate set of gambits, which will pull the ID data, either from URL param or from the API call.