<div dir="ltr"><div>I wanted to store a JSON object between agi requests for the duration of a call.</div><div><br></div><div>Turns out asterisk does NOT like a stringified JSON object! AGI complains of "520-Invalid command syntax"</div><div><br></div><div>So, I just base64 encode/decode it.</div><div><br></div><div>Assuming I don't need to manipulate the JSON object within Asterisk itself, and I don't want to use a DB or memcache, is this the best/correct method?</div><div>WARNING! Asterisk truncates long variables - seems to be about 3000 characters or so(?), so make sure your base64 encoded object is small!</div><div><br></div><div><div>The following is a simple example which just encodes and decodes the agi variables themselves as they're an object in ts-agi</div></div><div>(I'm using the ts-agi node package here as an example - <a href="https://github.com/sergey12313/ts-agi/">https://github.com/sergey12313/ts-agi/</a> )</div><br><div>    await ctx.setVariable('testvar2', Buffer.from(JSON.stringify(ctx.variables), 'utf8').toString('base64'))<br>    const testvar2 = (await ctx.getVariable('testvar2')).value<br>    const decoded = JSON.parse(Buffer.from(testvar2, 'base64').toString('utf8'))<br>    console.log('decoded is', decoded)<br></div><div><br></div><div><br></div><div>Hope this helps someone!</div></div>