kiran
kiran

Reputation: 23

Twilio Function - Variable values

I am trying to understand how the variable values can be referenced from event.Memory in Autopilot. Here is a simple test to explain what I am trying to achieve..

From the Bot model --> using remember action to store value

"remember": {
            "userIntent": "PrjSteps"
        }

In the Twilio function --> referencing variable

const memory=event.Memory;
console.log(memory);
console.log(memory.userIntent);

2019-12-11 10:56:44 UTC {"twilio":{"chat": {"ChannelSid":"xxxxxxxxxx","AssistantName":"","Attributes":{},"ServiceSid":"xxxxxxxx","Index":0,"From":"user","MessageSid":"xxxxxxxx"}},"userIntent":"PrjSteps"}

2019-12-11 10:56:44 UTC null

I see that the variable is available in the memory, but I am unable to access the value so I can validate inside the function.

Appreciate any help in this regard,

Thank you

Upvotes: 1

Views: 261

Answers (1)

Alan
Alan

Reputation: 10771

Try:

const memory = JSON.parse(event.Memory)

and then you should have access to the information.

Upvotes: 2

Related Questions