[{"data":1,"prerenderedAt":385},["ShallowReactive",2],{"help-article-integrations-custom-js-actions":3,"help-siblings-integrations":352},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"category":5,"order":10,"difficulty":11,"time_to_complete":12,"related":13,"body":17,"_type":346,"_id":347,"_source":348,"_file":349,"_stem":350,"_extension":351},"\u002Fhelp\u002Fintegrations\u002Fcustom-js-actions","integrations",false,"","Using the JavaScript VM for custom actions","How to write and execute JavaScript snippets as custom actions in conversations.",7,"advanced","4 minutes",[14,15,16],"\u002Fhelp\u002Fsettings\u002Fcustom-actions","\u002Fhelp\u002Fintegrations\u002Fapi-overview","\u002Fhelp\u002Fintegrations\u002Fwebhooks-receiving",{"type":18,"children":19,"toc":337},"root",[20,29,35,42,47,53,94,107,113,209,215,259,265,288,294],{"type":21,"tag":22,"props":23,"children":25},"element","h1",{"id":24},"javascript-vm-for-custom-actions",[26],{"type":27,"value":28},"text","JavaScript VM for custom actions",{"type":21,"tag":30,"props":31,"children":32},"p",{},[33],{"type":27,"value":34},"Execute JavaScript code as custom actions during conversations for advanced automation.",{"type":21,"tag":36,"props":37,"children":39},"h2",{"id":38},"what-is-the-js-vm",[40],{"type":27,"value":41},"What is the JS VM?",{"type":21,"tag":30,"props":43,"children":44},{},[45],{"type":27,"value":46},"AIsoule includes a sandboxed JavaScript virtual machine that can execute custom code when triggered by an agent or chatbot flow.",{"type":21,"tag":36,"props":48,"children":50},{"id":49},"creating-a-js-action",[51],{"type":27,"value":52},"Creating a JS action",{"type":21,"tag":54,"props":55,"children":56},"ol",{},[57,69,79,89],{"type":21,"tag":58,"props":59,"children":60},"li",{},[61,63],{"type":27,"value":62},"Go to ",{"type":21,"tag":64,"props":65,"children":66},"strong",{},[67],{"type":27,"value":68},"Settings → Custom Actions",{"type":21,"tag":58,"props":70,"children":71},{},[72,74],{"type":27,"value":73},"Click ",{"type":21,"tag":64,"props":75,"children":76},{},[77],{"type":27,"value":78},"\"New Action\"",{"type":21,"tag":58,"props":80,"children":81},{},[82,84],{"type":27,"value":83},"Select type: ",{"type":21,"tag":64,"props":85,"children":86},{},[87],{"type":27,"value":88},"JavaScript",{"type":21,"tag":58,"props":90,"children":91},{},[92],{"type":27,"value":93},"Write your code:",{"type":21,"tag":95,"props":96,"children":101},"pre",{"className":97,"code":99,"language":100,"meta":7},[98],"language-javascript","\u002F\u002F Available context:\n\u002F\u002F contact - current contact object\n\u002F\u002F message - last message\n\u002F\u002F agent - current agent\n\n\u002F\u002F Example: Format and return data\nconst result = {\n  formatted_phone: contact.phone_number.replace('+91', '0'),\n  greeting: `Hello ${contact.name || 'there'}!`\n};\n\nreturn result;\n","javascript",[102],{"type":21,"tag":103,"props":104,"children":105},"code",{"__ignoreMap":7},[106],{"type":27,"value":99},{"type":21,"tag":36,"props":108,"children":110},{"id":109},"available-context-variables",[111],{"type":27,"value":112},"Available context variables",{"type":21,"tag":114,"props":115,"children":116},"table",{},[117,136],{"type":21,"tag":118,"props":119,"children":120},"thead",{},[121],{"type":21,"tag":122,"props":123,"children":124},"tr",{},[125,131],{"type":21,"tag":126,"props":127,"children":128},"th",{},[129],{"type":27,"value":130},"Variable",{"type":21,"tag":126,"props":132,"children":133},{},[134],{"type":27,"value":135},"Contains",{"type":21,"tag":137,"props":138,"children":139},"tbody",{},[140,158,175,192],{"type":21,"tag":122,"props":141,"children":142},{},[143,153],{"type":21,"tag":144,"props":145,"children":146},"td",{},[147],{"type":21,"tag":103,"props":148,"children":150},{"className":149},[],[151],{"type":27,"value":152},"contact",{"type":21,"tag":144,"props":154,"children":155},{},[156],{"type":27,"value":157},"Contact object (name, phone, email, tags)",{"type":21,"tag":122,"props":159,"children":160},{},[161,170],{"type":21,"tag":144,"props":162,"children":163},{},[164],{"type":21,"tag":103,"props":165,"children":167},{"className":166},[],[168],{"type":27,"value":169},"message",{"type":21,"tag":144,"props":171,"children":172},{},[173],{"type":27,"value":174},"Last message object (text, type, timestamp)",{"type":21,"tag":122,"props":176,"children":177},{},[178,187],{"type":21,"tag":144,"props":179,"children":180},{},[181],{"type":21,"tag":103,"props":182,"children":184},{"className":183},[],[185],{"type":27,"value":186},"agent",{"type":21,"tag":144,"props":188,"children":189},{},[190],{"type":27,"value":191},"Current agent (name, email)",{"type":21,"tag":122,"props":193,"children":194},{},[195,204],{"type":21,"tag":144,"props":196,"children":197},{},[198],{"type":21,"tag":103,"props":199,"children":201},{"className":200},[],[202],{"type":27,"value":203},"organization",{"type":21,"tag":144,"props":205,"children":206},{},[207],{"type":27,"value":208},"Org details (name, id)",{"type":21,"tag":36,"props":210,"children":212},{"id":211},"limitations",[213],{"type":27,"value":214},"Limitations",{"type":21,"tag":216,"props":217,"children":218},"ul",{},[219,229,239,249],{"type":21,"tag":58,"props":220,"children":221},{},[222,227],{"type":21,"tag":64,"props":223,"children":224},{},[225],{"type":27,"value":226},"Timeout:",{"type":27,"value":228}," 5 seconds max execution",{"type":21,"tag":58,"props":230,"children":231},{},[232,237],{"type":21,"tag":64,"props":233,"children":234},{},[235],{"type":27,"value":236},"No network access:",{"type":27,"value":238}," Cannot make HTTP calls (use webhook type instead)",{"type":21,"tag":58,"props":240,"children":241},{},[242,247],{"type":21,"tag":64,"props":243,"children":244},{},[245],{"type":27,"value":246},"Sandboxed:",{"type":27,"value":248}," No access to filesystem or system APIs",{"type":21,"tag":58,"props":250,"children":251},{},[252,257],{"type":21,"tag":64,"props":253,"children":254},{},[255],{"type":27,"value":256},"Memory:",{"type":27,"value":258}," Limited to 10MB",{"type":21,"tag":36,"props":260,"children":262},{"id":261},"use-cases",[263],{"type":27,"value":264},"Use cases",{"type":21,"tag":216,"props":266,"children":267},{},[268,273,278,283],{"type":21,"tag":58,"props":269,"children":270},{},[271],{"type":27,"value":272},"Format data before displaying",{"type":21,"tag":58,"props":274,"children":275},{},[276],{"type":27,"value":277},"Calculate values (discounts, dates)",{"type":21,"tag":58,"props":279,"children":280},{},[281],{"type":27,"value":282},"Generate reference numbers",{"type":21,"tag":58,"props":284,"children":285},{},[286],{"type":27,"value":287},"Transform contact data",{"type":21,"tag":36,"props":289,"children":291},{"id":290},"tips",[292],{"type":27,"value":293},"Tips",{"type":21,"tag":54,"props":295,"children":296},{},[297,307,317,327],{"type":21,"tag":58,"props":298,"children":299},{},[300,305],{"type":21,"tag":64,"props":301,"children":302},{},[303],{"type":27,"value":304},"Keep it simple",{"type":27,"value":306}," — Complex logic belongs in webhooks",{"type":21,"tag":58,"props":308,"children":309},{},[310,315],{"type":21,"tag":64,"props":311,"children":312},{},[313],{"type":27,"value":314},"Handle errors",{"type":27,"value":316}," — Use try\u002Fcatch",{"type":21,"tag":58,"props":318,"children":319},{},[320,325],{"type":21,"tag":64,"props":321,"children":322},{},[323],{"type":27,"value":324},"Test locally",{"type":27,"value":326}," — Verify logic before deploying",{"type":21,"tag":58,"props":328,"children":329},{},[330,335],{"type":21,"tag":64,"props":331,"children":332},{},[333],{"type":27,"value":334},"Use for formatting",{"type":27,"value":336}," — Best for data transformation, not business logic",{"title":7,"searchDepth":338,"depth":338,"links":339},2,[340,341,342,343,344,345],{"id":38,"depth":338,"text":41},{"id":49,"depth":338,"text":52},{"id":109,"depth":338,"text":112},{"id":211,"depth":338,"text":214},{"id":261,"depth":338,"text":264},{"id":290,"depth":338,"text":293},"markdown","content:help:integrations:custom-js-actions.md","content","help\u002Fintegrations\u002Fcustom-js-actions.md","help\u002Fintegrations\u002Fcustom-js-actions","md",[353,355,358,359,362,365,368,371,374,377,379,382],{"_path":15,"title":354},"REST API overview and authentication",{"_path":356,"title":357},"\u002Fhelp\u002Fintegrations\u002Fapi-rate-limits","API rate limits and best practices",{"_path":4,"title":8},{"_path":360,"title":361},"\u002Fhelp\u002Fintegrations\u002Ferror-codes","Error codes reference",{"_path":363,"title":364},"\u002Fhelp\u002Fintegrations\u002Fpayment-gateway","Payment gateway setup (Razorpay\u002FStripe)",{"_path":366,"title":367},"\u002Fhelp\u002Fintegrations\u002Fproduct-catalog-sync","Product catalog sync from Meta",{"_path":369,"title":370},"\u002Fhelp\u002Fintegrations\u002Fsending-messages-api","Sending messages via API",{"_path":372,"title":373},"\u002Fhelp\u002Fintegrations\u002Fsending-messages-api-templates","Sending messages via API (advanced)",{"_path":375,"title":376},"\u002Fhelp\u002Fintegrations\u002Fwebhook-events","Webhook event types reference",{"_path":16,"title":378},"Receiving messages via webhooks",{"_path":380,"title":381},"\u002Fhelp\u002Fintegrations\u002Fwoocommerce","WooCommerce integration setup",{"_path":383,"title":384},"\u002Fhelp\u002Fintegrations\u002Fzapier-pabbly","Connecting with Zapier and Pabbly Connect",1780423187667]