[{"data":1,"prerenderedAt":748},["ShallowReactive",2],{"documentation-\u002Fdocumentation\u002Fwidget\u002Fjavascript-api":3},{"id":4,"title":5,"body":6,"description":738,"extension":739,"meta":740,"navigation":741,"ogImage":742,"path":743,"seo":744,"sitemap":745,"stem":746,"__hash__":747},"content\u002Fdocumentation\u002Fwidget\u002Fjavascript-api.md","Widget JavaScript API",{"type":7,"value":8,"toc":729},"minimark",[9,18,23,29,180,195,199,257,324,328,331,427,461,467,471,482,569,600,604,607,634,638,641,697,703,707,710,718,725],[10,11,12,13,17],"p",{},"Once the widget loads, it exposes ",[14,15,16],"code",{},"window.chatisto",". Use it to open the chat from your own buttons and to tell Chatisto who the visitor is.",[19,20,22],"h2",{"id":21},"wait-until-the-widget-is-ready","Wait until the widget is ready",[10,24,25,28],{},[14,26,27],{},"LoadChatisto()"," returns a promise that resolves once the widget is on the page. Put your calls there:",[30,31,36],"pre",{"className":32,"code":33,"language":34,"meta":35,"style":35},"language-js shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","window.chatistoLoader\n    .LoadChatisto({ publicKey: 'YOUR_PUBLIC_KEY' })\n    .then(() => {\n        window.chatisto.setProperty([{ key: 'email', value: 'jane@example.com' }]);\n    });\n","js","",[14,37,38,54,93,113,169],{"__ignoreMap":35},[39,40,43,47,51],"span",{"class":41,"line":42},"line",1,[39,44,46],{"class":45},"sTEyZ","window",[39,48,50],{"class":49},"sMK4o",".",[39,52,53],{"class":45},"chatistoLoader\n",[39,55,57,60,64,67,70,74,77,80,84,87,90],{"class":41,"line":56},2,[39,58,59],{"class":49},"    .",[39,61,63],{"class":62},"s2Zo4","LoadChatisto",[39,65,66],{"class":45},"(",[39,68,69],{"class":49},"{",[39,71,73],{"class":72},"swJcz"," publicKey",[39,75,76],{"class":49},":",[39,78,79],{"class":49}," '",[39,81,83],{"class":82},"sfazB","YOUR_PUBLIC_KEY",[39,85,86],{"class":49},"'",[39,88,89],{"class":49}," }",[39,91,92],{"class":45},")\n",[39,94,96,98,101,103,106,110],{"class":41,"line":95},3,[39,97,59],{"class":49},[39,99,100],{"class":62},"then",[39,102,66],{"class":45},[39,104,105],{"class":49},"()",[39,107,109],{"class":108},"spNyl"," =>",[39,111,112],{"class":49}," {\n",[39,114,116,119,121,124,126,129,132,134,137,139,141,144,146,149,152,154,156,159,161,163,166],{"class":41,"line":115},4,[39,117,118],{"class":45},"        window",[39,120,50],{"class":49},[39,122,123],{"class":45},"chatisto",[39,125,50],{"class":49},[39,127,128],{"class":62},"setProperty",[39,130,131],{"class":72},"([",[39,133,69],{"class":49},[39,135,136],{"class":72}," key",[39,138,76],{"class":49},[39,140,79],{"class":49},[39,142,143],{"class":82},"email",[39,145,86],{"class":49},[39,147,148],{"class":49},",",[39,150,151],{"class":72}," value",[39,153,76],{"class":49},[39,155,79],{"class":49},[39,157,158],{"class":82},"jane@example.com",[39,160,86],{"class":49},[39,162,89],{"class":49},[39,164,165],{"class":72},"])",[39,167,168],{"class":49},";\n",[39,170,172,175,178],{"class":41,"line":171},5,[39,173,174],{"class":49},"    }",[39,176,177],{"class":45},")",[39,179,168],{"class":49},[10,181,182,183,186,187,190,191,194],{},"The chat inside the widget may still be connecting at that moment. ",[14,184,185],{},"window.chatisto.widgetReady()"," returns ",[14,188,189],{},"true"," once it's fully started. ",[14,192,193],{},"setProperty()"," waits for this on its own, so you don't need to check.",[19,196,198],{"id":197},"open-the-chat-from-your-own-button","Open the chat from your own button",[30,200,204],{"className":201,"code":202,"language":203,"meta":35,"style":35},"language-html shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u003Cbutton onclick=\"window.chatisto.visual.open()\">Chat with us\u003C\u002Fbutton>\n","html",[14,205,206],{"__ignoreMap":35},[39,207,208,211,214,217,220,223,225,227,229,231,234,236,239,241,243,246,249,252,254],{"class":41,"line":42},[39,209,210],{"class":49},"\u003C",[39,212,213],{"class":72},"button",[39,215,216],{"class":108}," onclick",[39,218,219],{"class":49},"=",[39,221,222],{"class":49},"\"",[39,224,46],{"class":45},[39,226,50],{"class":49},[39,228,123],{"class":45},[39,230,50],{"class":49},[39,232,233],{"class":45},"visual",[39,235,50],{"class":49},[39,237,238],{"class":62},"open",[39,240,105],{"class":82},[39,242,222],{"class":49},[39,244,245],{"class":49},">",[39,247,248],{"class":45},"Chat with us",[39,250,251],{"class":49},"\u003C\u002F",[39,253,213],{"class":72},[39,255,256],{"class":49},">\n",[258,259,260,273],"table",{},[261,262,263],"thead",{},[264,265,266,270],"tr",{},[267,268,269],"th",{},"Method",[267,271,272],{},"What it does",[274,275,276,287,300,310],"tbody",{},[264,277,278,284],{},[279,280,281],"td",{},[14,282,283],{},"visual.open()",[279,285,286],{},"Opens the chat window.",[264,288,289,294],{},[279,290,291],{},[14,292,293],{},"show()",[279,295,296,297,299],{},"Deprecated. Clicks the chat bubble. Use ",[14,298,283],{}," instead.",[264,301,302,307],{},[279,303,304],{},[14,305,306],{},"destroy()",[279,308,309],{},"Removes the widget from the page.",[264,311,312,321],{},[279,313,314,317,318],{},[14,315,316],{},"visual.shadows.hide()"," \u002F ",[14,319,320],{},"visual.shadows.show()",[279,322,323],{},"Turns the widget's drop shadow off or on.",[19,325,327],{"id":326},"identify-logged-in-users","Identify logged-in users",[10,329,330],{},"By default every visitor is anonymous. If your visitors are logged in, pass what you know about them. Operators see it in the conversation sidebar and the contact profile, and it stays attached to the contact.",[30,332,334],{"className":32,"code":333,"language":34,"meta":35,"style":35},"window.chatisto.createCustomer({\n    email: 'jane@example.com',\n    name: 'Jane Cooper',\n    plan: 'Pro',\n    user_id: '48213'\n});\n",[14,335,336,354,370,386,402,417],{"__ignoreMap":35},[39,337,338,340,342,344,346,349,351],{"class":41,"line":42},[39,339,46],{"class":45},[39,341,50],{"class":49},[39,343,123],{"class":45},[39,345,50],{"class":49},[39,347,348],{"class":62},"createCustomer",[39,350,66],{"class":45},[39,352,353],{"class":49},"{\n",[39,355,356,359,361,363,365,367],{"class":41,"line":56},[39,357,358],{"class":72},"    email",[39,360,76],{"class":49},[39,362,79],{"class":49},[39,364,158],{"class":82},[39,366,86],{"class":49},[39,368,369],{"class":49},",\n",[39,371,372,375,377,379,382,384],{"class":41,"line":95},[39,373,374],{"class":72},"    name",[39,376,76],{"class":49},[39,378,79],{"class":49},[39,380,381],{"class":82},"Jane Cooper",[39,383,86],{"class":49},[39,385,369],{"class":49},[39,387,388,391,393,395,398,400],{"class":41,"line":115},[39,389,390],{"class":72},"    plan",[39,392,76],{"class":49},[39,394,79],{"class":49},[39,396,397],{"class":82},"Pro",[39,399,86],{"class":49},[39,401,369],{"class":49},[39,403,404,407,409,411,414],{"class":41,"line":171},[39,405,406],{"class":72},"    user_id",[39,408,76],{"class":49},[39,410,79],{"class":49},[39,412,413],{"class":82},"48213",[39,415,416],{"class":49},"'\n",[39,418,420,423,425],{"class":41,"line":419},6,[39,421,422],{"class":49},"}",[39,424,177],{"class":45},[39,426,168],{"class":49},[428,429,430,438,450],"ul",{},[431,432,433,434,437],"li",{},"Pass a plain object of ",[14,435,436],{},"key: value"," pairs. Each key you send becomes a contact field automatically.",[431,439,440,441,444,445,449],{},"Calling ",[14,442,443],{},"createCustomer()"," starts a ",[446,447,448],"strong",{},"new"," conversation for the visitor, so call it once after login. Don't call it on every page load.",[431,451,452,453,456,457,460],{},"It returns a promise that resolves with the visitor's identity (",[14,454,455],{},"customer"," and ",[14,458,459],{},"chatroom"," IDs).",[462,463,464],"blockquote",{},[10,465,466],{},"Never send passwords, payment details or other secrets. Anything you send is visible to your operators.",[19,468,470],{"id":469},"update-contact-properties","Update contact properties",[10,472,473,475,476,481],{},[14,474,193],{}," updates fields that already exist on the contact, for example a field collected by a ",[477,478,480],"a",{"href":479},"\u002Fdocumentation\u002Fscenarios","scenario"," form:",[30,483,485],{"className":32,"code":484,"language":34,"meta":35,"style":35},"window.chatisto.setProperty([\n    { key: 'email', value: 'jane@example.com' },\n    { key: 'newsletter-form.company', value: 'Acme Inc.' }\n]);\n",[14,486,487,502,532,563],{"__ignoreMap":35},[39,488,489,491,493,495,497,499],{"class":41,"line":42},[39,490,46],{"class":45},[39,492,50],{"class":49},[39,494,123],{"class":45},[39,496,50],{"class":49},[39,498,128],{"class":62},[39,500,501],{"class":45},"([\n",[39,503,504,507,509,511,513,515,517,519,521,523,525,527,529],{"class":41,"line":56},[39,505,506],{"class":49},"    {",[39,508,136],{"class":72},[39,510,76],{"class":49},[39,512,79],{"class":49},[39,514,143],{"class":82},[39,516,86],{"class":49},[39,518,148],{"class":49},[39,520,151],{"class":72},[39,522,76],{"class":49},[39,524,79],{"class":49},[39,526,158],{"class":82},[39,528,86],{"class":49},[39,530,531],{"class":49}," },\n",[39,533,534,536,538,540,542,545,547,549,551,553,555,558,560],{"class":41,"line":95},[39,535,506],{"class":49},[39,537,136],{"class":72},[39,539,76],{"class":49},[39,541,79],{"class":49},[39,543,544],{"class":82},"newsletter-form.company",[39,546,86],{"class":49},[39,548,148],{"class":49},[39,550,151],{"class":72},[39,552,76],{"class":49},[39,554,79],{"class":49},[39,556,557],{"class":82},"Acme Inc.",[39,559,86],{"class":49},[39,561,562],{"class":49}," }\n",[39,564,565,567],{"class":41,"line":115},[39,566,165],{"class":45},[39,568,168],{"class":49},[428,570,571,580,586,593],{},[431,572,573,576,577,50],{},[14,574,575],{},"key"," is the field key. To target a field in one specific form, use ",[14,578,579],{},"form-name.field-key",[431,581,582,585],{},[14,583,584],{},"value"," must be a string. Validation rules set on the field are applied, so an invalid email is rejected.",[431,587,588,589,592],{},"If you call it before the widget is ready, the call is queued and sent once the widget starts (it returns ",[14,590,591],{},"'queued'",").",[431,594,595,596,599],{},"The response lists each key with ",[14,597,598],{},"success: true\u002Ffalse"," and a reason, so you can see which fields didn't match.",[19,601,603],{"id":602},"start-a-fresh-conversation","Start a fresh conversation",[10,605,606],{},"A returning visitor continues their previous conversation if it was opened less than an hour ago. To force a clean start, for example after a user logs out:",[30,608,610],{"className":32,"code":609,"language":34,"meta":35,"style":35},"await window.chatisto.refreshIdentityAndRestartChat();\n",[14,611,612],{"__ignoreMap":35},[39,613,614,618,621,623,625,627,630,632],{"class":41,"line":42},[39,615,617],{"class":616},"s7zQu","await",[39,619,620],{"class":45}," window",[39,622,50],{"class":49},[39,624,123],{"class":45},[39,626,50],{"class":49},[39,628,629],{"class":62},"refreshIdentityAndRestartChat",[39,631,105],{"class":45},[39,633,168],{"class":49},[19,635,637],{"id":636},"reset-the-widget-completely","Reset the widget completely",[10,639,640],{},"For single-page apps that need to tear the widget down and load it again (for example, to switch to a different integration):",[30,642,644],{"className":32,"code":643,"language":34,"meta":35,"style":35},"window.chatistoLoader.resetChatisto();\nwindow.chatistoLoader.LoadChatisto({ publicKey: 'OTHER_PUBLIC_KEY' });\n",[14,645,646,664],{"__ignoreMap":35},[39,647,648,650,652,655,657,660,662],{"class":41,"line":42},[39,649,46],{"class":45},[39,651,50],{"class":49},[39,653,654],{"class":45},"chatistoLoader",[39,656,50],{"class":49},[39,658,659],{"class":62},"resetChatisto",[39,661,105],{"class":45},[39,663,168],{"class":49},[39,665,666,668,670,672,674,676,678,680,682,684,686,689,691,693,695],{"class":41,"line":56},[39,667,46],{"class":45},[39,669,50],{"class":49},[39,671,654],{"class":45},[39,673,50],{"class":49},[39,675,63],{"class":62},[39,677,66],{"class":45},[39,679,69],{"class":49},[39,681,73],{"class":72},[39,683,76],{"class":49},[39,685,79],{"class":49},[39,687,688],{"class":82},"OTHER_PUBLIC_KEY",[39,690,86],{"class":49},[39,692,89],{"class":49},[39,694,177],{"class":45},[39,696,168],{"class":49},[10,698,699,700,702],{},"Including the SDK script twice, or calling ",[14,701,27],{}," twice, is harmless. Chatisto keeps a single widget instance and logs a warning in the console.",[19,704,706],{"id":705},"buttons-inside-ai-and-scenario-messages","Buttons inside AI and scenario messages",[10,708,709],{},"Messages can contain clickable quick-reply buttons with this syntax:",[30,711,716],{"className":712,"code":714,"language":715,"meta":35},[713],"language-text","[BUTTON:Track my order|track_order|I need to track my order]\n","text",[14,717,714],{"__ignoreMap":35},[10,719,720,721,50],{},"The three parts are: the button label, an action name for your own tracking, and the message that is sent for the visitor when they click it. You can use it in scenario messages and in AI agent instructions or ",[477,722,724],{"href":723},"\u002Fdocumentation\u002Fai\u002Fskills","skills",[726,727,728],"style",{},"html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}",{"title":35,"searchDepth":56,"depth":56,"links":730},[731,732,733,734,735,736,737],{"id":21,"depth":56,"text":22},{"id":197,"depth":56,"text":198},{"id":326,"depth":56,"text":327},{"id":469,"depth":56,"text":470},{"id":602,"depth":56,"text":603},{"id":636,"depth":56,"text":637},{"id":705,"depth":56,"text":706},"Control the Chatisto widget from your code: open it, attach logged-in user data to the conversation, set contact properties and start a fresh chat.","md",{},true,null,"\u002Fdocumentation\u002Fwidget\u002Fjavascript-api",{"title":5,"description":738},{"loc":743},"documentation\u002Fwidget\u002Fjavascript-api","Gm52e75vmTUq88zojYfGe1hsM9Uw7krccckja0KGcSo",1794660404504]